… | |
… | |
164 | /* |
164 | /* |
165 | * struct member types: |
165 | * struct member types: |
166 | * private: you can look at them, but not change them, and they might not mean anything to you. |
166 | * private: you can look at them, but not change them, and they might not mean anything to you. |
167 | * ro: can be read anytime, but only changed when the watcher isn't active |
167 | * ro: can be read anytime, but only changed when the watcher isn't active |
168 | * rw: can be read and modified anytime, even when the watcher is active |
168 | * rw: can be read and modified anytime, even when the watcher is active |
|
|
169 | * |
|
|
170 | * some internal details that might be helpful for debugging: |
|
|
171 | * |
|
|
172 | * active is either 0, which means the watcher is not active, |
|
|
173 | * or the array index of the watcher (periodics, timers) |
|
|
174 | * or the array index + 1 (most other watchers) |
|
|
175 | * or simply 1 for watchers that aren't in some array. |
|
|
176 | * pending is either 0, in which case the watcher isn't, |
|
|
177 | * or the array index + 1 in the pendings array. |
169 | */ |
178 | */ |
170 | |
179 | |
171 | /* shared by all watchers */ |
180 | /* shared by all watchers */ |
172 | #define EV_WATCHER(type) \ |
181 | #define EV_WATCHER(type) \ |
173 | int active; /* private */ \ |
182 | int active; /* private */ \ |
… | |
… | |
513 | ((ev_watcher *)(void *)(ev))->priority = 0; \ |
522 | ((ev_watcher *)(void *)(ev))->priority = 0; \ |
514 | ev_set_cb ((ev), cb_); \ |
523 | ev_set_cb ((ev), cb_); \ |
515 | } while (0) |
524 | } while (0) |
516 | |
525 | |
517 | #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV_IOFDSET; } while (0) |
526 | #define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_) | EV_IOFDSET; } while (0) |
518 | #define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) |
527 | #define ev_timer_set(ev,after_,repeat_) do { ((ev_watcher_time *)(ev))->at = (after_); (ev)->repeat = (repeat_); } while (0) |
519 | #define ev_periodic_set(ev,ofs_,ival_,res_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0) |
528 | #define ev_periodic_set(ev,ofs_,ival_,res_) do { (ev)->offset = (ofs_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0) |
520 | #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) |
529 | #define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) |
521 | #define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0) |
530 | #define ev_child_set(ev,pid_,trace_) do { (ev)->pid = (pid_); (ev)->flags = !!(trace_); } while (0) |
522 | #define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0) |
531 | #define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); (ev)->wd = -2; } while (0) |
523 | #define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ |
532 | #define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ |
… | |
… | |
545 | |
554 | |
546 | #define ev_priority(ev) ((((ev_watcher *)(void *)(ev))->priority) + 0) |
555 | #define ev_priority(ev) ((((ev_watcher *)(void *)(ev))->priority) + 0) |
547 | #define ev_cb(ev) (ev)->cb /* rw */ |
556 | #define ev_cb(ev) (ev)->cb /* rw */ |
548 | #define ev_set_priority(ev,pri) ((ev_watcher *)(void *)(ev))->priority = (pri) |
557 | #define ev_set_priority(ev,pri) ((ev_watcher *)(void *)(ev))->priority = (pri) |
549 | |
558 | |
|
|
559 | #define ev_periodic_at(ev) (((ev_watcher_time *)(ev))->at + 0.) |
|
|
560 | |
550 | #ifndef ev_set_cb |
561 | #ifndef ev_set_cb |
551 | # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
562 | # define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) |
552 | #endif |
563 | #endif |
553 | |
564 | |
554 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |
565 | /* stopping (enabling, adding) a watcher does nothing if it is already running */ |