Announcing libasync, a cross-platform D event loop
Etienne via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 24 06:13:31 PDT 2014
It's finally here: https://github.com/etcimon/libasync
We all know how event loops are the foundation of more popular libraries
Qt and Nodejs.. we now have a natively compiling async library entirely
written in D.
This event library was tested on Win32, Linux x64, Mac OS x64, with DMD
2.066, offers the more low-level async objects: timers, file i/o, dns
resolver, tcp, udp, listeners, signals (cross-thread), notifications
(same thread), and more recently (and with great efforts for
implementing with OS X / BSD) a directory watcher.
e.g. You can run a timer with:
import std.datetime; import std.stdio; import libasync.all;
EventLoop evl = new EventLoop;
auto timer = new AsyncTimer(evl);
timer.duration(2.seconds).periodic().run({ writeln("Another 2 seconds
have passed"); });
while(evl.loop()) continue;
The tests may be most revealing:
https://github.com/etcimon/libasync/blob/master/source/libasync/test.d
A (lightly tested) vibe.d driver using all those async objects is also
available and currently ongoing a pull request:
https://github.com/etcimon/vibe.d/tree/native-events
The incentive was to make vibe.d compile in completely native D, I'm now
moving onto a botan C++ => D wrapper for it, I plan on moving objects to
D over the years until the TLS library can be completely native. I thank
Walter for the efforts on extern(C++)
Finally, I release this on the basis of an MIT license, looking forward
to seeing our community flourishing with yet more native libraries. Code on
More information about the Digitalmars-d
mailing list