Fixes for setTimer and SpinLock.
- setTimer now starts a task to call the callback. This keeps the timer referenced and avoids issues if I/O functions are called from within the callback. - SpinLock is now also initialized in "shared static this", so that applications using "shared static this" for initialization work properly.
This commit is contained in:
parent
3a3eb73006
commit
fc96ee9050
|
@ -872,8 +872,10 @@ Timer createTimer(void delegate() nothrow @safe callback)
|
|||
@safe nothrow {
|
||||
auto ret = Timer(eventDriver.timers.create());
|
||||
if (callback !is null) {
|
||||
void cb(TimerID tm) nothrow @safe { callback(); }
|
||||
eventDriver.timers.wait(ret.m_id, &cb); // FIXME: avoid heap closure!
|
||||
runTask((void delegate() nothrow @safe cb, Timer tm) {
|
||||
tm.wait();
|
||||
cb();
|
||||
}, callback, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -1302,6 +1304,9 @@ shared static this()
|
|||
|
||||
import std.concurrency;
|
||||
scheduler = new VibedScheduler;
|
||||
|
||||
import vibe.core.sync : SpinLock;
|
||||
SpinLock.setup();
|
||||
}
|
||||
|
||||
shared static ~this()
|
||||
|
|
Loading…
Reference in a new issue