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

Comparing libev/ev.c (file contents):
Revision 1.255 by root, Mon Jun 9 14:11:30 2008 UTC vs.
Revision 1.261 by root, Mon Sep 29 03:31:14 2008 UTC

154#ifndef _WIN32 154#ifndef _WIN32
155# include <sys/time.h> 155# include <sys/time.h>
156# include <sys/wait.h> 156# include <sys/wait.h>
157# include <unistd.h> 157# include <unistd.h>
158#else 158#else
159# include <io.h>
159# define WIN32_LEAN_AND_MEAN 160# define WIN32_LEAN_AND_MEAN
160# include <windows.h> 161# include <windows.h>
161# ifndef EV_SELECT_IS_WINSOCKET 162# ifndef EV_SELECT_IS_WINSOCKET
162# define EV_SELECT_IS_WINSOCKET 1 163# define EV_SELECT_IS_WINSOCKET 1
163# endif 164# endif
564 struct timeval tv; 565 struct timeval tv;
565 566
566 tv.tv_sec = (time_t)delay; 567 tv.tv_sec = (time_t)delay;
567 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); 568 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
568 569
570 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
571 /* somehting nto guaranteed by newer posix versions, but guaranteed */
572 /* by older ones */
569 select (0, 0, 0, 0, &tv); 573 select (0, 0, 0, 0, &tv);
570#endif 574#endif
571 } 575 }
572} 576}
573 577
1507{ 1511{
1508 postfork = 1; /* must be in line with ev_default_fork */ 1512 postfork = 1; /* must be in line with ev_default_fork */
1509} 1513}
1510 1514
1511#if EV_VERIFY 1515#if EV_VERIFY
1512void noinline 1516static void noinline
1513verify_watcher (EV_P_ W w) 1517verify_watcher (EV_P_ W w)
1514{ 1518{
1515 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); 1519 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
1516 1520
1517 if (w->pending) 1521 if (w->pending)
1903 1907
1904void 1908void
1905ev_unref (EV_P) 1909ev_unref (EV_P)
1906{ 1910{
1907 --activecnt; 1911 --activecnt;
1912}
1913
1914void
1915ev_now_update (EV_P)
1916{
1917 time_update (EV_A_ 1e100);
1908} 1918}
1909 1919
1910static int loop_done; 1920static int loop_done;
1911 1921
1912void 1922void
2823 ev_loop (EV_A_ EVLOOP_NONBLOCK); 2833 ev_loop (EV_A_ EVLOOP_NONBLOCK);
2824 } 2834 }
2825 } 2835 }
2826} 2836}
2827 2837
2838static void
2839embed_fork_cb (EV_P_ ev_fork *fork_w, int revents)
2840{
2841 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
2842
2843 {
2844 struct ev_loop *loop = w->other;
2845
2846 ev_loop_fork (EV_A);
2847 }
2848}
2849
2828#if 0 2850#if 0
2829static void 2851static void
2830embed_idle_cb (EV_P_ ev_idle *idle, int revents) 2852embed_idle_cb (EV_P_ ev_idle *idle, int revents)
2831{ 2853{
2832 ev_idle_stop (EV_A_ idle); 2854 ev_idle_stop (EV_A_ idle);
2852 2874
2853 ev_prepare_init (&w->prepare, embed_prepare_cb); 2875 ev_prepare_init (&w->prepare, embed_prepare_cb);
2854 ev_set_priority (&w->prepare, EV_MINPRI); 2876 ev_set_priority (&w->prepare, EV_MINPRI);
2855 ev_prepare_start (EV_A_ &w->prepare); 2877 ev_prepare_start (EV_A_ &w->prepare);
2856 2878
2879 ev_fork_init (&w->fork, embed_fork_cb);
2880 ev_fork_start (EV_A_ &w->fork);
2881
2857 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ 2882 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/
2858 2883
2859 ev_start (EV_A_ (W)w, 1); 2884 ev_start (EV_A_ (W)w, 1);
2860 2885
2861 EV_FREQUENT_CHECK; 2886 EV_FREQUENT_CHECK;
2868 if (expect_false (!ev_is_active (w))) 2893 if (expect_false (!ev_is_active (w)))
2869 return; 2894 return;
2870 2895
2871 EV_FREQUENT_CHECK; 2896 EV_FREQUENT_CHECK;
2872 2897
2873 ev_io_stop (EV_A_ &w->io); 2898 ev_io_stop (EV_A_ &w->io);
2874 ev_prepare_stop (EV_A_ &w->prepare); 2899 ev_prepare_stop (EV_A_ &w->prepare);
2875 2900 ev_fork_stop (EV_A_ &w->fork);
2876 ev_stop (EV_A_ (W)w);
2877 2901
2878 EV_FREQUENT_CHECK; 2902 EV_FREQUENT_CHECK;
2879} 2903}
2880#endif 2904#endif
2881 2905
2978once_cb (EV_P_ struct ev_once *once, int revents) 3002once_cb (EV_P_ struct ev_once *once, int revents)
2979{ 3003{
2980 void (*cb)(int revents, void *arg) = once->cb; 3004 void (*cb)(int revents, void *arg) = once->cb;
2981 void *arg = once->arg; 3005 void *arg = once->arg;
2982 3006
2983 ev_io_stop (EV_A_ &once->io); 3007 ev_io_stop (EV_A_ &once->io);
2984 ev_timer_stop (EV_A_ &once->to); 3008 ev_timer_stop (EV_A_ &once->to);
2985 ev_free (once); 3009 ev_free (once);
2986 3010
2987 cb (revents, arg); 3011 cb (revents, arg);
2988} 3012}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines