… | |
… | |
508 | * (such as failed select, poll, epoll_wait) |
508 | * (such as failed select, poll, epoll_wait) |
509 | */ |
509 | */ |
510 | void ev_set_syserr_cb (void (*cb)(const char *msg)); |
510 | void ev_set_syserr_cb (void (*cb)(const char *msg)); |
511 | |
511 | |
512 | #if EV_MULTIPLICITY |
512 | #if EV_MULTIPLICITY |
|
|
513 | |
|
|
514 | /* the default loop is the only one that handles signals and child watchers */ |
|
|
515 | /* you can call this as often as you like */ |
|
|
516 | struct ev_loop *ev_default_loop (unsigned int flags EV_CPP (= 0)); |
|
|
517 | |
513 | EV_INLINE struct ev_loop * |
518 | EV_INLINE struct ev_loop * |
514 | ev_default_loop_uc (void) |
519 | ev_default_loop_uc (void) |
515 | { |
520 | { |
516 | extern struct ev_loop *ev_default_loop_ptr; |
521 | extern struct ev_loop *ev_default_loop_ptr; |
517 | |
522 | |
518 | return ev_default_loop_ptr; |
523 | return ev_default_loop_ptr; |
519 | } |
524 | } |
520 | |
525 | |
521 | /* the default loop is the only one that handles signals and child watchers */ |
526 | EV_INLINE int |
522 | /* you can call this as often as you like */ |
527 | ev_is_default_loop (EV_P) |
523 | EV_INLINE struct ev_loop * |
|
|
524 | ev_default_loop (unsigned int flags EV_CPP (= 0)) |
|
|
525 | { |
528 | { |
526 | struct ev_loop *loop = ev_default_loop_uc (); |
529 | return EV_A == ev_default_loop_uc (); |
527 | |
|
|
528 | if (!loop) |
|
|
529 | { |
|
|
530 | extern struct ev_loop *ev_default_loop_init (unsigned int flags); |
|
|
531 | |
|
|
532 | loop = ev_default_loop_init (flags); |
|
|
533 | } |
|
|
534 | |
|
|
535 | return loop; |
|
|
536 | } |
530 | } |
537 | |
531 | |
538 | /* create and destroy alternative loops that don't handle signals */ |
532 | /* create and destroy alternative loops that don't handle signals */ |
539 | struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); |
533 | struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); |
540 | void ev_loop_destroy (EV_P); |
534 | void ev_loop_destroy (EV_P); |
… | |
… | |
551 | { |
545 | { |
552 | extern ev_tstamp ev_rt_now; |
546 | extern ev_tstamp ev_rt_now; |
553 | |
547 | |
554 | return ev_rt_now; |
548 | return ev_rt_now; |
555 | } |
549 | } |
|
|
550 | |
|
|
551 | /* looks weird, but ev_is_default_loop (EV_A) still works if this exists */ |
|
|
552 | EV_INLINE int |
|
|
553 | ev_is_default_loop (void) |
|
|
554 | { |
|
|
555 | return 1; |
|
|
556 | } |
|
|
557 | |
556 | #endif /* multiplicity */ |
558 | #endif /* multiplicity */ |
557 | |
|
|
558 | EV_INLINE int |
|
|
559 | ev_is_default_loop (EV_P) |
|
|
560 | { |
|
|
561 | #if EV_MULTIPLICITY |
|
|
562 | extern struct ev_loop *ev_default_loop_ptr; |
|
|
563 | |
|
|
564 | return !!(EV_A == ev_default_loop_ptr); |
|
|
565 | #else |
|
|
566 | return 1; |
|
|
567 | #endif |
|
|
568 | } |
|
|
569 | |
559 | |
570 | void ev_default_destroy (void); /* destroy the default loop */ |
560 | void ev_default_destroy (void); /* destroy the default loop */ |
571 | /* this needs to be called after fork, to duplicate the default loop */ |
561 | /* this needs to be called after fork, to duplicate the default loop */ |
572 | /* if you create alternative loops you have to call ev_loop_fork on them */ |
562 | /* 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 */ |
563 | /* you can call it in either the parent or the child */ |