Allow switchToTask to be called within a yield lock.

Enables waking up other tasks from within a yield lock (executed after the yield lock is lifted).
This commit is contained in:
Sönke Ludwig 2018-09-09 11:35:39 +02:00
parent b5177894d2
commit 2480f6bb67

View file

@ -689,7 +689,8 @@ void hibernate(scope void delegate() @safe nothrow on_interrupt = null)
*/ */
void switchToTask(Task t) void switchToTask(Task t)
@safe nothrow { @safe nothrow {
s_scheduler.switchTo(t); auto defer = TaskFiber.getThis().m_yieldLockCount > 0 ? Yes.defer : No.defer;
s_scheduler.switchTo(t, defer);
} }