void Core::Suspend() { auto tid = this_thread::get_id(); // If recursive, just increment the count { lock_guard<mutex> lock(d->AccessMutex); if (d->df_suspend_depth > 0 && d->df_suspend_thread == tid) { d->df_suspend_depth++; return; } } // put the condition on a stack Core::Cond *nc = new Core::Cond(); { lock_guard<mutex> lock2(d->StackMutex); d->suspended_tools.push(nc); } // wait until Core::Update() wakes up the tool { lock_guard<mutex> lock(d->AccessMutex); nc->Lock(&d->AccessMutex); assert(d->df_suspend_depth == 0); d->df_suspend_thread = tid; d->df_suspend_depth = 1; } }
void Core::Suspend() { Core::Cond * nc = new Core::Cond(); // put the condition on a stack StackMutex->lock(); suspended_tools.push(nc); StackMutex->unlock(); // wait until Core::Update() wakes up the tool AccessMutex->lock(); nc->Lock(AccessMutex); AccessMutex->unlock(); }