vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Function createLeanTimer

Creates a new timer with a lean callback mechanism.

Timer createLeanTimer(CALLABLE) (
  CALLABLE callback
)
if (is(typeof(() nothrow @safe { callback(); } ())) || is(typeof(() nothrow @safe { callback(Timer.init); } ())));

In contrast to the standard createTimer, callback will not be called in a new task, but is instead called directly in the context of the event loop.

For this reason, the supplied callback is not allowed to perform any operation that needs to block/yield execution. In this case, runTask needs to be used explicitly to perform the operation asynchronously.

Additionally, callback can carry arbitrary state without requiring a heap allocation.

See also

createTimer

Authors

Sönke Ludwig

Copyright

© 2012-2020 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.