==== ev.d ==== .. highlight:: d Introduction ============ **ev.d** is both a low and high level libev_ bindings for the `D Programming Language`_ . All modules are placed in the ``ev`` package. .. note:: libev_ should be compiled with ``EV_MULTIPLICITY=1`` to work with **ev.d**. Low level API (``ev.c``) ======================== The low level bindings directly expose the C API, without any specific D magic. You can almost port a simple C libev example changing a few lines of code, for example:: import ev.c; // .... void main() { ev_io stdin_watcher; auto loop = ev_default_loop(); /* initialise an io watcher, then start it */ ev_io_init(&stdin_watcher, &stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); ev_io_start(loop, &stdin_watcher); /* loop till timeout or data ready */ ev_loop(loop, 0); } For a complete example see `ctest.d`__. __ https://git.llucax.com/w/software/ev.d.git/blob/HEAD:/ctest.d High level API (``ev.d``) ========================= The high level API adds some D sugar on top of the low level API, providing a more D-ish experience. You can use delegates to handle events and is a little more object oriented. Here is a very simple example:: import std.stdio; import ev.d; void main() { (new Timer(5.5, (Timer w, int revents) { writefln("timeout, revents = ", revents); w.loop.unloop(Unloop.ONE); // example syntax } )).start; loop.loop; } For a complete example see `dtest.d`__. __ https://git.llucax.com/w/software/ev.d.git/blob/HEAD:/dtest.d Compile-time options ==================== You can disable specific watchers types at compile-time (this should be in sync with libev watchers support). To do that, use version ``EV_ENABLE_SELECT`` and then select the specific watchers you want to enable. For example: ``gdc -fversion=EV_ENABLE_SELECT -fversion=EV_STAT_ENABLE`` to enable only the ``ev_stat`` extra watcher. Download ======== There are no proper releases yet, but mainly because the code is so simple, not because the code is not working or stable enough. You can get the code from the Git_ repository__ (you can get a tarball there too, if you don't have Git_ installed). __ https://git.llucax.com/w/software/ev.d.git Support ======= If you have any problems/comments/suggestions, you can contact me directly at luca@llucax.com. If at any time there is enough people interested in **ev.d** I might open a mailing list for it, but for now it seems overkill to do so =). Author ====== **ev.d** was written by Leandro Lucarella. License ======= **ev.d** is placed under the BOLA_ License which is basically Public Domain. .. _libev: http://software.schmorp.de/pkg/libev.html .. _`D Programming Language`: http://www.digitalmars.com/d/ .. _BOLA: http://auriga.wearlab.de/~alb/bola/ .. _Git: http://git.or.cz/ .. vim: set et sw=3 sts=3 tw=78 :