mirror of https://github.com/KLayout/klayout.git
commit
7635b784bb
|
|
@ -118,15 +118,26 @@ DeferredMethodScheduler::do_execute ()
|
||||||
// do the execution outside the locked range to avoid deadlocks if the method's execution
|
// do the execution outside the locked range to avoid deadlocks if the method's execution
|
||||||
// schedules another call.
|
// schedules another call.
|
||||||
for (std::list<DeferredMethodBase *>::iterator m = m_executing.begin (); m != m_executing.end (); ++m) {
|
for (std::list<DeferredMethodBase *>::iterator m = m_executing.begin (); m != m_executing.end (); ++m) {
|
||||||
|
|
||||||
bool still_valid;
|
bool still_valid;
|
||||||
|
|
||||||
m_lock.lock ();
|
m_lock.lock ();
|
||||||
// during execution a method may be unqueued - make sure this is not executed
|
// during execution a method may be unqueued - make sure this is not executed
|
||||||
still_valid = (m_unqueued.find (*m) == m_unqueued.end ());
|
still_valid = (m_unqueued.find (*m) == m_unqueued.end ());
|
||||||
m_lock.unlock ();
|
m_lock.unlock ();
|
||||||
|
|
||||||
if (still_valid) {
|
if (still_valid) {
|
||||||
|
|
||||||
(*m)->m_scheduled = false;
|
(*m)->m_scheduled = false;
|
||||||
(*m)->execute ();
|
(*m)->execute ();
|
||||||
|
|
||||||
|
// execute() may have triggered another do_execute which we should consider here and stop:
|
||||||
|
if (m_executing.empty ()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lock.lock ();
|
m_lock.lock ();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue