… | |
… | |
162 | # define EV_A_ EV_A, |
162 | # define EV_A_ EV_A, |
163 | # define EV_DEFAULT_UC ev_default_loop_uc () |
163 | # define EV_DEFAULT_UC ev_default_loop_uc () |
164 | # define EV_DEFAULT_UC_ EV_DEFAULT_UC, |
164 | # define EV_DEFAULT_UC_ EV_DEFAULT_UC, |
165 | # define EV_DEFAULT ev_default_loop (0) |
165 | # define EV_DEFAULT ev_default_loop (0) |
166 | # define EV_DEFAULT_ EV_DEFAULT, |
166 | # define EV_DEFAULT_ EV_DEFAULT, |
|
|
167 | # define EV_PDEF EV_P EV_DEFARG (EV_DEFAULT_UC) |
167 | #else |
168 | #else |
168 | # define EV_P void |
169 | # define EV_P void |
169 | # define EV_P_ |
170 | # define EV_P_ |
170 | # define EV_A |
171 | # define EV_A |
171 | # define EV_A_ |
172 | # define EV_A_ |
172 | # define EV_DEFAULT |
173 | # define EV_DEFAULT |
173 | # define EV_DEFAULT_ |
174 | # define EV_DEFAULT_ |
174 | # define EV_DEFAULT_UC |
175 | # define EV_DEFAULT_UC |
175 | # define EV_DEFAULT_UC_ |
176 | # define EV_DEFAULT_UC_ |
|
|
177 | # define EV_PDEF EV_P |
176 | # undef EV_EMBED_ENABLE |
178 | # undef EV_EMBED_ENABLE |
177 | #endif |
179 | #endif |
178 | |
180 | |
179 | #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 |
181 | #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 |
180 | # define EV_INLINE static inline |
182 | # define EV_INLINE static inline |
… | |
… | |
535 | return loop; |
537 | return loop; |
536 | } |
538 | } |
537 | |
539 | |
538 | /* create and destroy alternative loops that don't handle signals */ |
540 | /* create and destroy alternative loops that don't handle signals */ |
539 | struct ev_loop *ev_loop_new (unsigned int flags EV_DEFARG (0)); |
541 | struct ev_loop *ev_loop_new (unsigned int flags EV_DEFARG (0)); |
540 | void ev_loop_destroy (EV_P); |
542 | void ev_loop_destroy (EV_PDEF); |
541 | void ev_loop_fork (EV_P); |
543 | void ev_loop_fork (EV_PDEF); |
542 | |
544 | |
543 | ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ |
545 | ev_tstamp ev_now (EV_PDEF); /* time w.r.t. timers and the eventloop, updated after each poll */ |
544 | |
546 | |
545 | #else |
547 | #else |
546 | |
548 | |
547 | int ev_default_loop (unsigned int flags EV_DEFARG (0)); /* returns true when successful */ |
549 | int ev_default_loop (unsigned int flags EV_DEFARG (0)); /* returns true when successful */ |
548 | |
550 | |
… | |
… | |
554 | return ev_rt_now; |
556 | return ev_rt_now; |
555 | } |
557 | } |
556 | #endif /* multiplicity */ |
558 | #endif /* multiplicity */ |
557 | |
559 | |
558 | EV_INLINE int |
560 | EV_INLINE int |
559 | ev_is_default_loop (EV_P) |
561 | ev_is_default_loop (EV_PDEF) |
560 | { |
562 | { |
561 | #if EV_MULTIPLICITY |
563 | #if EV_MULTIPLICITY |
562 | extern struct ev_loop *ev_default_loop_ptr; |
564 | extern struct ev_loop *ev_default_loop_ptr; |
563 | |
565 | |
564 | return !!(EV_A == ev_default_loop_ptr); |
566 | return !!(EV_A == ev_default_loop_ptr); |
… | |
… | |
572 | /* if you create alternative loops you have to call ev_loop_fork on them */ |
574 | /* if you create alternative loops you have to call ev_loop_fork on them */ |
573 | /* you can call it in either the parent or the child */ |
575 | /* you can call it in either the parent or the child */ |
574 | /* you can actually call it at any time, anywhere :) */ |
576 | /* you can actually call it at any time, anywhere :) */ |
575 | void ev_default_fork (void); |
577 | void ev_default_fork (void); |
576 | |
578 | |
577 | unsigned int ev_backend (EV_P); /* backend in use by loop */ |
579 | unsigned int ev_backend (EV_PDEF); /* backend in use by loop */ |
578 | |
580 | |
579 | void ev_now_update (EV_P); /* update event loop time */ |
581 | void ev_now_update (EV_PDEF); /* update event loop time */ |
580 | |
582 | |
581 | #if EV_WALK_ENABLE |
583 | #if EV_WALK_ENABLE |
582 | /* walk (almost) all watchers in the loop of a given type, invoking the */ |
584 | /* walk (almost) all watchers in the loop of a given type, invoking the */ |
583 | /* callback on every such watcher. The callback might stop the watcher, */ |
585 | /* callback on every such watcher. The callback might stop the watcher, */ |
584 | /* but do nothing else with the loop */ |
586 | /* but do nothing else with the loop */ |
… | |
… | |
607 | /* |
609 | /* |
608 | * ref/unref can be used to add or remove a refcount on the mainloop. every watcher |
610 | * ref/unref can be used to add or remove a refcount on the mainloop. every watcher |
609 | * keeps one reference. if you have a long-running watcher you never unregister that |
611 | * keeps one reference. if you have a long-running watcher you never unregister that |
610 | * should not keep ev_loop from running, unref() after starting, and ref() before stopping. |
612 | * should not keep ev_loop from running, unref() after starting, and ref() before stopping. |
611 | */ |
613 | */ |
612 | void ev_ref (EV_P); |
614 | void ev_ref (EV_PDEF); |
613 | void ev_unref (EV_P); |
615 | void ev_unref (EV_PDEF); |
614 | |
616 | |
615 | /* |
617 | /* |
616 | * convenience function, wait for a single event, without registering an event watcher |
618 | * convenience function, wait for a single event, without registering an event watcher |
617 | * if timeout is < 0, do wait indefinitely |
619 | * if timeout is < 0, do wait indefinitely |
618 | */ |
620 | */ |
619 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
621 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
620 | |
622 | |
621 | # if EV_FEATURE_API |
623 | # if EV_FEATURE_API |
622 | unsigned int ev_iteration (EV_P); /* number of loop iterations */ |
624 | unsigned int ev_iteration (EV_PDEF); /* number of loop iterations */ |
623 | unsigned int ev_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ |
625 | unsigned int ev_depth (EV_PDEF); /* #ev_loop enters - #ev_loop leaves */ |
624 | void ev_verify (EV_P); /* abort if loop data corrupted */ |
626 | void ev_verify (EV_PDEF); /* abort if loop data corrupted */ |
625 | |
627 | |
626 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
628 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
627 | void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
629 | void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
628 | |
630 | |
629 | /* advanced stuff for threading etc. support, see docs */ |
631 | /* advanced stuff for threading etc. support, see docs */ |
630 | void ev_set_userdata (EV_P_ void *data); |
632 | void ev_set_userdata (EV_P_ void *data); |
631 | void *ev_userdata (EV_P); |
633 | void *ev_userdata (EV_PDEF); |
632 | void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)); |
634 | void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)); |
633 | void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P)); |
635 | void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P)); |
634 | |
636 | |
635 | unsigned int ev_pending_count (EV_P); /* number of pending events, if any */ |
637 | unsigned int ev_pending_count (EV_PDEF); /* number of pending events, if any */ |
636 | void ev_invoke_pending (EV_P); /* invoke all pending watchers */ |
638 | void ev_invoke_pending (EV_PDEF); /* invoke all pending watchers */ |
637 | |
639 | |
638 | /* |
640 | /* |
639 | * stop/start the timer handling. |
641 | * stop/start the timer handling. |
640 | */ |
642 | */ |
641 | void ev_suspend (EV_P); |
643 | void ev_suspend (EV_PDEF); |
642 | void ev_resume (EV_P); |
644 | void ev_resume (EV_PDEF); |
643 | #endif |
645 | #endif |
644 | |
646 | |
645 | #endif |
647 | #endif |
646 | |
648 | |
647 | /* these may evaluate ev multiple times, and the other arguments at most once */ |
649 | /* these may evaluate ev multiple times, and the other arguments at most once */ |