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

Comparing libev/ev.c (file contents):
Revision 1.422 by root, Wed Apr 18 06:09:29 2012 UTC vs.
Revision 1.425 by root, Sun May 6 13:09:35 2012 UTC

359#endif 359#endif
360 360
361/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ 361/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
362/* which makes programs even slower. might work on other unices, too. */ 362/* which makes programs even slower. might work on other unices, too. */
363#if EV_USE_CLOCK_SYSCALL 363#if EV_USE_CLOCK_SYSCALL
364# include <syscall.h> 364# include <sys/syscall.h>
365# ifdef SYS_clock_gettime 365# ifdef SYS_clock_gettime
366# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) 366# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
367# undef EV_USE_MONOTONIC 367# undef EV_USE_MONOTONIC
368# define EV_USE_MONOTONIC 1 368# define EV_USE_MONOTONIC 1
369# else 369# else
1430 w_->pending = ++pendingcnt [pri]; 1430 w_->pending = ++pendingcnt [pri];
1431 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); 1431 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2);
1432 pendings [pri][w_->pending - 1].w = w_; 1432 pendings [pri][w_->pending - 1].w = w_;
1433 pendings [pri][w_->pending - 1].events = revents; 1433 pendings [pri][w_->pending - 1].events = revents;
1434 } 1434 }
1435
1436 pendingpri = NUMPRI - 1;
1435} 1437}
1436 1438
1437inline_speed void 1439inline_speed void
1438feed_reverse (EV_P_ W w) 1440feed_reverse (EV_P_ W w)
1439{ 1441{
1844} 1846}
1845 1847
1846inline_speed void 1848inline_speed void
1847evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1849evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1848{ 1850{
1851 ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */
1852
1849 if (expect_true (*flag)) 1853 if (expect_true (*flag))
1850 return; 1854 return;
1851 1855
1852 *flag = 1; 1856 *flag = 1;
1853 1857
1912 } 1916 }
1913 } 1917 }
1914 1918
1915 pipe_write_skipped = 0; 1919 pipe_write_skipped = 0;
1916 1920
1921 ECB_MEMORY_FENCE; /* push out skipped, acquire flags */
1922
1917#if EV_SIGNAL_ENABLE 1923#if EV_SIGNAL_ENABLE
1918 if (sig_pending) 1924 if (sig_pending)
1919 { 1925 {
1920 sig_pending = 0; 1926 sig_pending = 0;
1927
1928 ECB_MEMORY_FENCE_RELEASE;
1921 1929
1922 for (i = EV_NSIG - 1; i--; ) 1930 for (i = EV_NSIG - 1; i--; )
1923 if (expect_false (signals [i].pending)) 1931 if (expect_false (signals [i].pending))
1924 ev_feed_signal_event (EV_A_ i + 1); 1932 ev_feed_signal_event (EV_A_ i + 1);
1925 } 1933 }
1927 1935
1928#if EV_ASYNC_ENABLE 1936#if EV_ASYNC_ENABLE
1929 if (async_pending) 1937 if (async_pending)
1930 { 1938 {
1931 async_pending = 0; 1939 async_pending = 0;
1940
1941 ECB_MEMORY_FENCE_RELEASE;
1932 1942
1933 for (i = asynccnt; i--; ) 1943 for (i = asynccnt; i--; )
1934 if (asyncs [i]->sent) 1944 if (asyncs [i]->sent)
1935 { 1945 {
1936 asyncs [i]->sent = 0; 1946 asyncs [i]->sent = 0;
2677} 2687}
2678 2688
2679void noinline 2689void noinline
2680ev_invoke_pending (EV_P) 2690ev_invoke_pending (EV_P)
2681{ 2691{
2682 int pri; 2692 for (pendingpri = NUMPRI; pendingpri--; ) /* pendingpri is modified during the loop */
2683
2684 for (pri = NUMPRI; pri--; )
2685 while (pendingcnt [pri]) 2693 while (pendingcnt [pendingpri])
2686 { 2694 {
2687 ANPENDING *p = pendings [pri] + --pendingcnt [pri]; 2695 ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri];
2688 2696
2689 p->w->pending = 0; 2697 p->w->pending = 0;
2690 EV_CB_INVOKE (p->w, p->events); 2698 EV_CB_INVOKE (p->w, p->events);
2691 EV_FREQUENT_CHECK; 2699 EV_FREQUENT_CHECK;
2692 } 2700 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines