… | |
… | |
263 | #endif |
263 | #endif |
264 | |
264 | |
265 | /* these may evaluate ev multiple times, and the other arguments at most once */ |
265 | /* these may evaluate ev multiple times, and the other arguments at most once */ |
266 | /* either use ev_watcher_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ |
266 | /* either use ev_watcher_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ |
267 | #define ev_watcher_init(ev,cb_) do { \ |
267 | #define ev_watcher_init(ev,cb_) do { \ |
268 | ((struct ev_watcher *)(ev))->active = \ |
268 | ((struct ev_watcher *)(void *)(ev))->active = \ |
269 | ((struct ev_watcher *)(ev))->pending = \ |
269 | ((struct ev_watcher *)(void *)(ev))->pending = \ |
270 | ((struct ev_watcher *)(ev))->priority = 0; \ |
270 | ((struct ev_watcher *)(void *)(ev))->priority = 0; \ |
271 | (ev)->cb = (cb_); \ |
271 | (ev)->cb = (cb_); \ |
272 | } while (0) |
272 | } while (0) |
273 | |
273 | |
274 | #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) |
274 | #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) |
275 | #define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) |
275 | #define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) |
… | |
… | |
287 | #define ev_idle_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) |
287 | #define ev_idle_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) |
288 | #define ev_prepare_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) |
288 | #define ev_prepare_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) |
289 | #define ev_check_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_check_set ((ev)); } while (0) |
289 | #define ev_check_init(ev,cb) do { ev_watcher_init ((ev), (cb)); ev_check_set ((ev)); } while (0) |
290 | #define ev_child_init(ev,cb,pid) do { ev_watcher_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0) |
290 | #define ev_child_init(ev,cb,pid) do { ev_watcher_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0) |
291 | |
291 | |
292 | #define ev_is_pending(ev) (0 + ((struct ev_watcher *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ |
292 | #define ev_is_pending(ev) (0 + ((struct ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ |
293 | #define ev_is_active(ev) (0 + ((struct ev_watcher *)(ev))->active) /* ro, true when the watcher has been started */ |
293 | #define ev_is_active(ev) (0 + ((struct ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ |
294 | |
294 | |
295 | #define ev_priority(ev) ((struct ev_watcher *)(ev))->priority /* rw */ |
295 | #define ev_priority(ev) ((struct ev_watcher *)(void *)(ev))->priority /* rw */ |
296 | #define ev_cb(ev) (ev)->cb /* rw */ |
296 | #define ev_cb(ev) (ev)->cb /* rw */ |
297 | #define ev_set_priority(ev,pri) ev_priority (ev) = (pri) |
297 | #define ev_set_priority(ev,pri) ev_priority (ev) = (pri) |
298 | #define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
298 | #define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
299 | |
299 | |
300 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |
300 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |