From 7803fdaa814632dc2b26f4b3d2588bc569e58207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 13 Jan 2017 22:08:12 +0100 Subject: [PATCH] Make Task.interrupt nothrow + add diagnostic assertion. --- source/vibe/core/task.d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/vibe/core/task.d b/source/vibe/core/task.d index 76f50ac..57ef8a5 100644 --- a/source/vibe/core/task.d +++ b/source/vibe/core/task.d @@ -84,7 +84,7 @@ struct Task { T opCast(T)() const @safe nothrow if (is(T == bool)) { return m_fiber !is null; } void join() @trusted { if (running) taskFiber.join(m_taskCounter); } // FIXME: this is NOT thread safe - void interrupt() @trusted { if (running) taskFiber.interrupt(m_taskCounter); } // FIXME: this is NOT thread safe + void interrupt() @trusted nothrow { if (running) taskFiber.interrupt(m_taskCounter); } // FIXME: this is NOT thread safe string toString() const @safe { import std.string; return format("%s:%s", () @trusted { return cast(void*)m_fiber; } (), m_taskCounter); } @@ -426,7 +426,7 @@ final package class TaskFiber : Fiber { /** Throws an InterruptExeption within the task as soon as it calls an interruptible function. */ void interrupt(size_t task_counter) - @safe { + @safe nothrow { import vibe.core.core : taskScheduler; if (m_taskCounter != task_counter) @@ -702,6 +702,8 @@ package struct TaskScheduler { if (!m_markerTask) m_markerTask = new TaskFiber; // TODO: avoid allocating an actual task here! + scope (exit) assert(!m_markerTask.m_queue, "Marker task still in queue!?"); + assert(Task.getThis() == Task.init, "TaskScheduler.schedule() may not be called from a task!"); assert(!m_markerTask.m_queue, "TaskScheduler.schedule() was called recursively!");