From b5ccb784a1e758b72932715b813c51cbc00defb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 22 Jan 2019 11:39:31 +0100 Subject: [PATCH] Allow Task.interrupt to be called within a yieldLock. --- source/vibe/core/task.d | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/vibe/core/task.d b/source/vibe/core/task.d index 22ad957..70bddb3 100644 --- a/source/vibe/core/task.d +++ b/source/vibe/core/task.d @@ -491,7 +491,9 @@ final package class TaskFiber : Fiber { } else assert(() @trusted { return Thread.getThis(); } () is this.thread, "Interrupting tasks in different threads is not yet supported."); debug (VibeTaskLog) logTrace("Resuming task with interrupt flag."); m_interrupt = true; - taskScheduler.switchTo(this.task); + + auto defer = TaskFiber.getThis().m_yieldLockCount > 0 ? Yes.defer : No.defer; + taskScheduler.switchTo(this.task, defer); } void bumpTaskCounter()