X-Git-Url: https://git.llucax.com/software/ev.d.git/blobdiff_plain/a3183560b58dce04159910ec20b2e8458c4063e4..34195d6560498fdddedaea0934e8e3a51f53d929:/test.d diff --git a/test.d b/test.d index 27b1c90..aede490 100644 --- a/test.d +++ b/test.d @@ -10,22 +10,22 @@ +/ import io = std.stdio; -import ev; +import ev.c; extern (C) { - static void stdin_cb (ev_loop_t* loop, ev_io *w, int revents) + static void stdin_cb(ev_loop_t* loop, ev_io *w, int revents) { io.writefln("stdin ready"); char[] ln = io.readln(); io.writef("read %d bytes: %s", ln.length, ln); ev_io_stop(loop, w); // just a syntax example - ev_unloop(loop, how.ALL); // leave all loop calls + ev_unloop(loop, EVUNLOOP_ALL); // leave all loop calls } static void timeout_cb(ev_loop_t* loop, ev_timer *w, int revents) { io.writefln("timeout"); - ev_unloop(loop, how.ONE); // leave one loop call + ev_unloop(loop, EVUNLOOP_ONE); // leave one loop call } } @@ -34,10 +34,10 @@ void main() ev_io stdin_watcher; ev_timer timeout_watcher; - ev_loop_t* loop = ev_default_loop(); + auto loop = ev_default_loop(); /* initialise an io watcher, then start it */ - ev_io_init(&stdin_watcher, &stdin_cb, /*STDIN_FILENO*/ 0, READ); + ev_io_init(&stdin_watcher, &stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); ev_io_start(loop, &stdin_watcher); /* simple non-repeating 5.5 second timeout */