Duration of sleep.
a function called when operation finished or an error occurred.
1 import dpromise.utils : runEventloop; 2 import std.datetime : Clock, UTC; 3 4 auto startTime = Clock.currTime(UTC()); 5 sleepAsyncWithCallback(100.msecs, (e) nothrow { 6 try { 7 auto dur = Clock.currTime(UTC()) - startTime; 8 assert(dur + 4.msecs > 100.msecs); 9 assert(dur - 4.msecs < 100.msecs); 10 } catch(Exception e) {} 11 }); 12 13 runEventloop();
Sleep in asynchronous while dur then calls the callback function.
If an error occurred, the callback function will be called with the error.