Merge pull request #236 from vibe-d/fix_task_interrupt_assertion_failure
Avoid bogus "A task cannot interrupt itself" assertion failure.
This commit is contained in:
commit
983cc15f70
|
@ -97,7 +97,14 @@ struct Task {
|
||||||
|
|
||||||
void join() @trusted { if (m_fiber) m_fiber.join!true(m_taskCounter); }
|
void join() @trusted { if (m_fiber) m_fiber.join!true(m_taskCounter); }
|
||||||
void joinUninterruptible() @trusted nothrow { if (m_fiber) m_fiber.join!false(m_taskCounter); }
|
void joinUninterruptible() @trusted nothrow { if (m_fiber) m_fiber.join!false(m_taskCounter); }
|
||||||
void interrupt() @trusted nothrow { if (m_fiber) m_fiber.interrupt(m_taskCounter); }
|
void interrupt() @trusted nothrow { if (m_fiber && this.running) m_fiber.interrupt(m_taskCounter); }
|
||||||
|
|
||||||
|
unittest { // regression test for bogus "task cannot interrupt itself"
|
||||||
|
import vibe.core.core : runTask;
|
||||||
|
auto t = runTask({});
|
||||||
|
t.join();
|
||||||
|
runTask({ t.interrupt(); }).join();
|
||||||
|
}
|
||||||
|
|
||||||
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); }
|
||||||
|
|
||||||
|
@ -138,7 +145,6 @@ struct Task {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Settings to control the behavior of newly started tasks.
|
/** Settings to control the behavior of newly started tasks.
|
||||||
*/
|
*/
|
||||||
struct TaskSettings {
|
struct TaskSettings {
|
||||||
|
|
Loading…
Reference in a new issue