Merge pull request #106 from vibe-d/issue-104-unreferenced-periodic-timers

Fix unreferenced periodic timers
This commit is contained in:
Sönke Ludwig 2018-11-23 19:07:49 +01:00 committed by GitHub
commit c5443f0fc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -1103,7 +1103,7 @@ struct TimerCallbackHandler {
cb(); cb();
} }
if (!eventDriver.timers.isUnique(timer)) if (!eventDriver.timers.isUnique(timer) || eventDriver.timers.isPending(timer))
eventDriver.timers.wait(timer, &handle); eventDriver.timers.wait(timer, &handle);
} }
} }

View file

@ -0,0 +1,23 @@
/+ dub.sdl:
name "test"
dependency "vibe-core" path=".."
+/
module test;
import vibe.core.core;
import core.memory;
import core.time;
int main()
{
setTimer(10.seconds, { assert(false, "Event loop didn't exit in time."); });
// make sure that periodic timers for which no explicit reference is stored
// are still getting invoked periodically
size_t i = 0;
setTimer(50.msecs, { if (i++ == 3) exitEventLoop(); }, true);
return runEventLoop();
}