ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.336 by root, Wed Mar 10 08:19:38 2010 UTC vs.
Revision 1.337 by root, Wed Mar 10 09:18:24 2010 UTC

891} 891}
892 892
893/*****************************************************************************/ 893/*****************************************************************************/
894 894
895inline_speed void 895inline_speed void
896fd_event_nc (EV_P_ int fd, int revents) 896fd_event_nocheck (EV_P_ int fd, int revents)
897{ 897{
898 ANFD *anfd = anfds + fd; 898 ANFD *anfd = anfds + fd;
899 ev_io *w; 899 ev_io *w;
900 900
901 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) 901 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
913fd_event (EV_P_ int fd, int revents) 913fd_event (EV_P_ int fd, int revents)
914{ 914{
915 ANFD *anfd = anfds + fd; 915 ANFD *anfd = anfds + fd;
916 916
917 if (expect_true (!anfd->reify)) 917 if (expect_true (!anfd->reify))
918 fd_event_nc (EV_A_ fd, revents); 918 fd_event_nocheck (EV_A_ fd, revents);
919} 919}
920 920
921void 921void
922ev_feed_fd_event (EV_P_ int fd, int revents) 922ev_feed_fd_event (EV_P_ int fd, int revents)
923{ 923{
924 if (fd >= 0 && fd < anfdmax) 924 if (fd >= 0 && fd < anfdmax)
925 fd_event_nc (EV_A_ fd, revents); 925 fd_event_nocheck (EV_A_ fd, revents);
926} 926}
927 927
928/* make sure the external fd watch events are in-sync */ 928/* make sure the external fd watch events are in-sync */
929/* with the kernel/libev internal state */ 929/* with the kernel/libev internal state */
930inline_size void 930inline_size void
1798 { 1798 {
1799 EV_WIN32_CLOSE_FD (evpipe [0]); 1799 EV_WIN32_CLOSE_FD (evpipe [0]);
1800 EV_WIN32_CLOSE_FD (evpipe [1]); 1800 EV_WIN32_CLOSE_FD (evpipe [1]);
1801 } 1801 }
1802 1802
1803#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1803 evpipe_init (EV_A); 1804 evpipe_init (EV_A);
1804 /* now iterate over everything, in case we missed something */ 1805 /* now iterate over everything, in case we missed something */
1805 pipecb (EV_A_ &pipe_w, EV_READ); 1806 pipecb (EV_A_ &pipe_w, EV_READ);
1807#endif
1806 } 1808 }
1807 1809
1808 postfork = 0; 1810 postfork = 0;
1809} 1811}
1810 1812
1923#if EV_ASYNC_ENABLE 1925#if EV_ASYNC_ENABLE
1924 assert (asyncmax >= asynccnt); 1926 assert (asyncmax >= asynccnt);
1925 array_verify (EV_A_ (W *)asyncs, asynccnt); 1927 array_verify (EV_A_ (W *)asyncs, asynccnt);
1926#endif 1928#endif
1927 1929
1930#if EV_PREPARE_ENABLE
1928 assert (preparemax >= preparecnt); 1931 assert (preparemax >= preparecnt);
1929 array_verify (EV_A_ (W *)prepares, preparecnt); 1932 array_verify (EV_A_ (W *)prepares, preparecnt);
1933#endif
1930 1934
1935#if EV_CHECK_ENABLE
1931 assert (checkmax >= checkcnt); 1936 assert (checkmax >= checkcnt);
1932 array_verify (EV_A_ (W *)checks, checkcnt); 1937 array_verify (EV_A_ (W *)checks, checkcnt);
1938#endif
1933 1939
1934# if 0 1940# if 0
1935#if EV_CHILD_ENABLE 1941#if EV_CHILD_ENABLE
1936 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1942 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
1937 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) 1943 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
2304 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2310 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2305 EV_INVOKE_PENDING; 2311 EV_INVOKE_PENDING;
2306 } 2312 }
2307#endif 2313#endif
2308 2314
2315#if EV_PREPARE_ENABLE
2309 /* queue prepare watchers (and execute them) */ 2316 /* queue prepare watchers (and execute them) */
2310 if (expect_false (preparecnt)) 2317 if (expect_false (preparecnt))
2311 { 2318 {
2312 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2319 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2313 EV_INVOKE_PENDING; 2320 EV_INVOKE_PENDING;
2314 } 2321 }
2322#endif
2315 2323
2316 if (expect_false (loop_done)) 2324 if (expect_false (loop_done))
2317 break; 2325 break;
2318 2326
2319 /* we might have forked, so reify kernel state if necessary */ 2327 /* we might have forked, so reify kernel state if necessary */
2392#if EV_IDLE_ENABLE 2400#if EV_IDLE_ENABLE
2393 /* queue idle watchers unless other events are pending */ 2401 /* queue idle watchers unless other events are pending */
2394 idle_reify (EV_A); 2402 idle_reify (EV_A);
2395#endif 2403#endif
2396 2404
2405#if EV_CHECK_ENABLE
2397 /* queue check watchers, to be executed first */ 2406 /* queue check watchers, to be executed first */
2398 if (expect_false (checkcnt)) 2407 if (expect_false (checkcnt))
2399 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2408 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2409#endif
2400 2410
2401 EV_INVOKE_PENDING; 2411 EV_INVOKE_PENDING;
2402 } 2412 }
2403 while (expect_true ( 2413 while (expect_true (
2404 activecnt 2414 activecnt
3318 3328
3319 EV_FREQUENT_CHECK; 3329 EV_FREQUENT_CHECK;
3320} 3330}
3321#endif 3331#endif
3322 3332
3333#if EV_PREPARE_ENABLE
3323void 3334void
3324ev_prepare_start (EV_P_ ev_prepare *w) 3335ev_prepare_start (EV_P_ ev_prepare *w)
3325{ 3336{
3326 if (expect_false (ev_is_active (w))) 3337 if (expect_false (ev_is_active (w)))
3327 return; 3338 return;
3353 3364
3354 ev_stop (EV_A_ (W)w); 3365 ev_stop (EV_A_ (W)w);
3355 3366
3356 EV_FREQUENT_CHECK; 3367 EV_FREQUENT_CHECK;
3357} 3368}
3369#endif
3358 3370
3371#if EV_CHECK_ENABLE
3359void 3372void
3360ev_check_start (EV_P_ ev_check *w) 3373ev_check_start (EV_P_ ev_check *w)
3361{ 3374{
3362 if (expect_false (ev_is_active (w))) 3375 if (expect_false (ev_is_active (w)))
3363 return; 3376 return;
3389 3402
3390 ev_stop (EV_A_ (W)w); 3403 ev_stop (EV_A_ (W)w);
3391 3404
3392 EV_FREQUENT_CHECK; 3405 EV_FREQUENT_CHECK;
3393} 3406}
3407#endif
3394 3408
3395#if EV_EMBED_ENABLE 3409#if EV_EMBED_ENABLE
3396void noinline 3410void noinline
3397ev_embed_sweep (EV_P_ ev_embed *w) 3411ev_embed_sweep (EV_P_ ev_embed *w)
3398{ 3412{
3727 if (types & EV_ASYNC) 3741 if (types & EV_ASYNC)
3728 for (i = asynccnt; i--; ) 3742 for (i = asynccnt; i--; )
3729 cb (EV_A_ EV_ASYNC, asyncs [i]); 3743 cb (EV_A_ EV_ASYNC, asyncs [i]);
3730#endif 3744#endif
3731 3745
3746#if EV_PREPARE_ENABLE
3732 if (types & EV_PREPARE) 3747 if (types & EV_PREPARE)
3733 for (i = preparecnt; i--; ) 3748 for (i = preparecnt; i--; )
3734#if EV_EMBED_ENABLE 3749# if EV_EMBED_ENABLE
3735 if (ev_cb (prepares [i]) != embed_prepare_cb) 3750 if (ev_cb (prepares [i]) != embed_prepare_cb)
3736#endif 3751# endif
3737 cb (EV_A_ EV_PREPARE, prepares [i]); 3752 cb (EV_A_ EV_PREPARE, prepares [i]);
3753#endif
3738 3754
3755#if EV_CHECK_ENABLE
3739 if (types & EV_CHECK) 3756 if (types & EV_CHECK)
3740 for (i = checkcnt; i--; ) 3757 for (i = checkcnt; i--; )
3741 cb (EV_A_ EV_CHECK, checks [i]); 3758 cb (EV_A_ EV_CHECK, checks [i]);
3759#endif
3742 3760
3761#if EV_SIGNAL_ENABLE
3743 if (types & EV_SIGNAL) 3762 if (types & EV_SIGNAL)
3744 for (i = 0; i < EV_NSIG - 1; ++i) 3763 for (i = 0; i < EV_NSIG - 1; ++i)
3745 for (wl = signals [i].head; wl; ) 3764 for (wl = signals [i].head; wl; )
3746 { 3765 {
3747 wn = wl->next; 3766 wn = wl->next;
3748 cb (EV_A_ EV_SIGNAL, wl); 3767 cb (EV_A_ EV_SIGNAL, wl);
3749 wl = wn; 3768 wl = wn;
3750 } 3769 }
3770#endif
3751 3771
3772#if EV_CHILD_ENABLE
3752 if (types & EV_CHILD) 3773 if (types & EV_CHILD)
3753 for (i = EV_PID_HASHSIZE; i--; ) 3774 for (i = EV_PID_HASHSIZE; i--; )
3754 for (wl = childs [i]; wl; ) 3775 for (wl = childs [i]; wl; )
3755 { 3776 {
3756 wn = wl->next; 3777 wn = wl->next;
3757 cb (EV_A_ EV_CHILD, wl); 3778 cb (EV_A_ EV_CHILD, wl);
3758 wl = wn; 3779 wl = wn;
3759 } 3780 }
3781#endif
3760/* EV_STAT 0x00001000 /* stat data changed */ 3782/* EV_STAT 0x00001000 /* stat data changed */
3761/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ 3783/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */
3762} 3784}
3763#endif 3785#endif
3764 3786

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines