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