From 2480f6bb6794253a67c5706412264ee002e01a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 9 Sep 2018 11:35:39 +0200 Subject: [PATCH] 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). --- source/vibe/core/core.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/vibe/core/core.d b/source/vibe/core/core.d index 47cb048..d4caf36 100644 --- a/source/vibe/core/core.d +++ b/source/vibe/core/core.d @@ -689,7 +689,8 @@ void hibernate(scope void delegate() @safe nothrow on_interrupt = null) */ void switchToTask(Task t) @safe nothrow { - s_scheduler.switchTo(t); + auto defer = TaskFiber.getThis().m_yieldLockCount > 0 ? Yes.defer : No.defer; + s_scheduler.switchTo(t, defer); }