Make Task.interrupt nothrow + add diagnostic assertion.
This commit is contained in:
parent
ece639ee01
commit
7803fdaa81
|
@ -84,7 +84,7 @@ struct Task {
|
||||||
T opCast(T)() const @safe nothrow if (is(T == bool)) { return m_fiber !is null; }
|
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 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); }
|
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.
|
/** Throws an InterruptExeption within the task as soon as it calls an interruptible function.
|
||||||
*/
|
*/
|
||||||
void interrupt(size_t task_counter)
|
void interrupt(size_t task_counter)
|
||||||
@safe {
|
@safe nothrow {
|
||||||
import vibe.core.core : taskScheduler;
|
import vibe.core.core : taskScheduler;
|
||||||
|
|
||||||
if (m_taskCounter != task_counter)
|
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!
|
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(Task.getThis() == Task.init, "TaskScheduler.schedule() may not be called from a task!");
|
||||||
assert(!m_markerTask.m_queue, "TaskScheduler.schedule() was called recursively!");
|
assert(!m_markerTask.m_queue, "TaskScheduler.schedule() was called recursively!");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue