Thread overview | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 24, 2014 Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
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 |
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On 9/24/14, 6:13 AM, Etienne wrote:
> It's finally here: https://github.com/etcimon/libasync
This is fantastic! We really need something like this in a Facebook project.
Would be appropriate for you to consider making a bid for adding it to Phobos? In that case one issue to address is integrating std.concurrency with the event loop, i.e. registering an event handler should be possible for a thread message as well. The Boost license would need to be added. What do you think?
Andrei
|
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On Wednesday, 24 September 2014 at 13:13:34 UTC, Etienne wrote:
> 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
Do I understand correctly that it is similar library to boost.asio (EventLoop being equivalent of asio::io_service)?
|
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | > This is fantastic! We really need something like this in a Facebook > project. That's pleasing to hear, although I'm pretty sure Facebook is far from being the only organization who will benefit from this ;) > Would be appropriate for you to consider making a bid for adding it to Phobos? Thanks for the invitation, I'll start working on a phobos fork with this added into std.async and re-licensed to Boost. Would that be an appropriate namespace? > In that case one issue to address is integrating std.concurrency > with the event loop, i.e. registering an event handler should be > possible for a thread message as well. Of course, the libasync.threads module already has a good foothold on the strategy, so a newer/better std.concurrency could deprecate parts of this module by offering an adapted message queue that allows threads with an event loop to communicate with threads that have one or not, in both directions. > Do I understand correctly that it is similar library to boost.asio (EventLoop being equivalent of asio::io_service)? That's right, but instead of io_service::run() you call eventloop.loop(). In both cases, it's a wrapper around epoll_wait (linux), kqueue (osx/bsd) or MsgWaitForMultipleObjects (windows) with a timeout parameter. It waits for the objects supplied by the library. The "strands" feature is pretty much covered by the vibe.d tasks if you're using the driver I wrote for it. |
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On Wednesday, 24 September 2014 at 13:13:34 UTC, Etienne wrote:
> 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.
I am very excited about this. Thank you for this awesome contribution, you made my day :)
|
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On 9/24/14, 9:30 AM, Etienne wrote: > > This is fantastic! We really need something like this in a Facebook > > project. > > That's pleasing to hear, although I'm pretty sure Facebook is far from > being the only organization who will benefit from this ;) > > > Would be appropriate for you to consider making a bid for adding it > to Phobos? > > Thanks for the invitation, I'll start working on a phobos fork with this > added into std.async and re-licensed to Boost. Would that be an > appropriate namespace? Yes. Thanks! > > In that case one issue to address is integrating std.concurrency > > with the event loop, i.e. registering an event handler should be > > possible for a thread message as well. > > Of course, the libasync.threads module already has a good foothold on > the strategy, so a newer/better std.concurrency could deprecate parts of > this module by offering an adapted message queue that allows threads > with an event loop to communicate with threads that have one or not, in > both directions. Yah, I think that's where the most design effort around porting would go. Andrei |
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On 9/24/14, 6:13 AM, Etienne wrote: > It's finally here: https://github.com/etcimon/libasync http://www.reddit.com/r/programming/comments/2hcm9n/announcing_libasync_a_crossplatform_d_event_loop/ Andrei |
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne | On 2014-09-24 15:13, Etienne wrote: > 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. Shouldn't the directory watcher use FSEvents on OS X? -- /Jacob Carlborg |
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 2014-09-24 3:15 PM, Jacob Carlborg wrote:
> Shouldn't the directory watcher use FSEvents on OS X?
>
I've thought about it but it isn't compatible with other BSD platforms and has no docs about using it with kqueue, it ended up looking more complicated and unstable because I could read complaints everywhere I looked. It ended up putting me in a direction where I needed separate threads with their own event loops and communication through signals, which didn't fit in with what I was used to doing from what the other platforms offered.
I found the solution with kqueue's vnode, which acts like inotify. It doesn't have recursion nor file modification events when watching folders so individual files had to be watched and the directories checked against cache data every time an event came in. It seems a lot more flexible on the long run, and making feature additions / compatibility adjustments didn't sound like a nightmare on the long run.
|
September 24, 2014 Re: Announcing libasync, a cross-platform D event loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne Attachments: | On Wed, 24 Sep 2014 09:13:31 -0400
Etienne via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> 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.
it's great! and it will be even greater ;-) to have this in phobos.
thank you for your work.
|
Copyright © 1999-2021 by the D Language Foundation