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

Comparing libev/ev.c (file contents):
Revision 1.229 by root, Fri May 2 08:08:45 2008 UTC vs.
Revision 1.230 by root, Fri May 2 08:13:16 2008 UTC

772 /* maybe we could use a dummy element at heap [0]? */ 772 /* maybe we could use a dummy element at heap [0]? */
773 if (!p || heap [p]->at <= w->at) 773 if (!p || heap [p]->at <= w->at)
774 break; 774 break;
775 775
776 heap [k] = heap [p]; 776 heap [k] = heap [p];
777 ((W)heap [k])->active = k; 777 ev_active (heap [k]) = k;
778 k = p; 778 k = p;
779 } 779 }
780 780
781 heap [k] = w; 781 heap [k] = w;
782 ((W)heap [k])->active = k; 782 ev_active (heap [k]) = k;
783} 783}
784 784
785/* away from the root */ 785/* away from the root */
786void inline_speed 786void inline_speed
787downheap (WT *heap, int N, int k) 787downheap (WT *heap, int N, int k)
800 800
801 if (w->at <= heap [c]->at) 801 if (w->at <= heap [c]->at)
802 break; 802 break;
803 803
804 heap [k] = heap [c]; 804 heap [k] = heap [c];
805 ((W)heap [k])->active = k; 805 ev_active (heap [k]) = k;
806 806
807 k = c; 807 k = c;
808 } 808 }
809 809
810 heap [k] = w; 810 heap [k] = w;
811 ((W)heap [k])->active = k; 811 ev_active (heap [k]) = k;
812} 812}
813 813
814void inline_size 814void inline_size
815adjustheap (WT *heap, int N, int k) 815adjustheap (WT *heap, int N, int k)
816{ 816{
1895 ev_start (EV_A_ (W)w, ++timercnt); 1895 ev_start (EV_A_ (W)w, ++timercnt);
1896 array_needsize (WT, timers, timermax, timercnt + 1, EMPTY2); 1896 array_needsize (WT, timers, timermax, timercnt + 1, EMPTY2);
1897 timers [timercnt] = (WT)w; 1897 timers [timercnt] = (WT)w;
1898 upheap (timers, timercnt); 1898 upheap (timers, timercnt);
1899 1899
1900 /*assert (("internal timer heap corruption", timers [((W)w)->active] == w));*/ 1900 /*assert (("internal timer heap corruption", timers [ev_active (w)] == w));*/
1901} 1901}
1902 1902
1903void noinline 1903void noinline
1904ev_timer_stop (EV_P_ ev_timer *w) 1904ev_timer_stop (EV_P_ ev_timer *w)
1905{ 1905{
1906 clear_pending (EV_A_ (W)w); 1906 clear_pending (EV_A_ (W)w);
1907 if (expect_false (!ev_is_active (w))) 1907 if (expect_false (!ev_is_active (w)))
1908 return; 1908 return;
1909 1909
1910 assert (("internal timer heap corruption", timers [((W)w)->active] == (WT)w));
1911
1912 { 1910 {
1913 int active = ((W)w)->active; 1911 int active = ev_active (w);
1912
1913 assert (("internal timer heap corruption", timers [active] == (WT)w));
1914 1914
1915 if (expect_true (active < timercnt)) 1915 if (expect_true (active < timercnt))
1916 { 1916 {
1917 timers [active] = timers [timercnt]; 1917 timers [active] = timers [timercnt];
1918 adjustheap (timers, timercnt, active); 1918 adjustheap (timers, timercnt, active);
1932 if (ev_is_active (w)) 1932 if (ev_is_active (w))
1933 { 1933 {
1934 if (w->repeat) 1934 if (w->repeat)
1935 { 1935 {
1936 ev_at (w) = mn_now + w->repeat; 1936 ev_at (w) = mn_now + w->repeat;
1937 adjustheap (timers, timercnt, ((W)w)->active); 1937 adjustheap (timers, timercnt, ev_active (w));
1938 } 1938 }
1939 else 1939 else
1940 ev_timer_stop (EV_A_ w); 1940 ev_timer_stop (EV_A_ w);
1941 } 1941 }
1942 else if (w->repeat) 1942 else if (w->repeat)
1967 ev_start (EV_A_ (W)w, ++periodiccnt); 1967 ev_start (EV_A_ (W)w, ++periodiccnt);
1968 array_needsize (WT, periodics, periodicmax, periodiccnt + 1, EMPTY2); 1968 array_needsize (WT, periodics, periodicmax, periodiccnt + 1, EMPTY2);
1969 periodics [periodiccnt] = (WT)w; 1969 periodics [periodiccnt] = (WT)w;
1970 upheap (periodics, periodiccnt); 1970 upheap (periodics, periodiccnt);
1971 1971
1972 /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/ 1972 /*assert (("internal periodic heap corruption", periodics [ev_active (w)] == w));*/
1973} 1973}
1974 1974
1975void noinline 1975void noinline
1976ev_periodic_stop (EV_P_ ev_periodic *w) 1976ev_periodic_stop (EV_P_ ev_periodic *w)
1977{ 1977{
1978 clear_pending (EV_A_ (W)w); 1978 clear_pending (EV_A_ (W)w);
1979 if (expect_false (!ev_is_active (w))) 1979 if (expect_false (!ev_is_active (w)))
1980 return; 1980 return;
1981 1981
1982 assert (("internal periodic heap corruption", periodics [((W)w)->active] == (WT)w));
1983
1984 { 1982 {
1985 int active = ((W)w)->active; 1983 int active = ev_active (w);
1984
1985 assert (("internal periodic heap corruption", periodics [active] == (WT)w));
1986 1986
1987 if (expect_true (active < periodiccnt)) 1987 if (expect_true (active < periodiccnt))
1988 { 1988 {
1989 periodics [active] = periodics [periodiccnt]; 1989 periodics [active] = periodics [periodiccnt];
1990 adjustheap (periodics, periodiccnt, active); 1990 adjustheap (periodics, periodiccnt, active);
2368 clear_pending (EV_A_ (W)w); 2368 clear_pending (EV_A_ (W)w);
2369 if (expect_false (!ev_is_active (w))) 2369 if (expect_false (!ev_is_active (w)))
2370 return; 2370 return;
2371 2371
2372 { 2372 {
2373 int active = ((W)w)->active; 2373 int active = ev_active (w);
2374 2374
2375 idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; 2375 idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]];
2376 ((W)idles [ABSPRI (w)][active - 1])->active = active; 2376 ev_active (idles [ABSPRI (w)][active - 1]) = active;
2377 2377
2378 ev_stop (EV_A_ (W)w); 2378 ev_stop (EV_A_ (W)w);
2379 --idleall; 2379 --idleall;
2380 } 2380 }
2381} 2381}
2398 clear_pending (EV_A_ (W)w); 2398 clear_pending (EV_A_ (W)w);
2399 if (expect_false (!ev_is_active (w))) 2399 if (expect_false (!ev_is_active (w)))
2400 return; 2400 return;
2401 2401
2402 { 2402 {
2403 int active = ((W)w)->active; 2403 int active = ev_active (w);
2404
2404 prepares [active - 1] = prepares [--preparecnt]; 2405 prepares [active - 1] = prepares [--preparecnt];
2405 ((W)prepares [active - 1])->active = active; 2406 ev_active (prepares [active - 1]) = active;
2406 } 2407 }
2407 2408
2408 ev_stop (EV_A_ (W)w); 2409 ev_stop (EV_A_ (W)w);
2409} 2410}
2410 2411
2425 clear_pending (EV_A_ (W)w); 2426 clear_pending (EV_A_ (W)w);
2426 if (expect_false (!ev_is_active (w))) 2427 if (expect_false (!ev_is_active (w)))
2427 return; 2428 return;
2428 2429
2429 { 2430 {
2430 int active = ((W)w)->active; 2431 int active = ev_active (w);
2432
2431 checks [active - 1] = checks [--checkcnt]; 2433 checks [active - 1] = checks [--checkcnt];
2432 ((W)checks [active - 1])->active = active; 2434 ev_active (checks [active - 1]) = active;
2433 } 2435 }
2434 2436
2435 ev_stop (EV_A_ (W)w); 2437 ev_stop (EV_A_ (W)w);
2436} 2438}
2437 2439
2533 clear_pending (EV_A_ (W)w); 2535 clear_pending (EV_A_ (W)w);
2534 if (expect_false (!ev_is_active (w))) 2536 if (expect_false (!ev_is_active (w)))
2535 return; 2537 return;
2536 2538
2537 { 2539 {
2538 int active = ((W)w)->active; 2540 int active = ev_active (w);
2541
2539 forks [active - 1] = forks [--forkcnt]; 2542 forks [active - 1] = forks [--forkcnt];
2540 ((W)forks [active - 1])->active = active; 2543 ev_active (forks [active - 1]) = active;
2541 } 2544 }
2542 2545
2543 ev_stop (EV_A_ (W)w); 2546 ev_stop (EV_A_ (W)w);
2544} 2547}
2545#endif 2548#endif
2564 clear_pending (EV_A_ (W)w); 2567 clear_pending (EV_A_ (W)w);
2565 if (expect_false (!ev_is_active (w))) 2568 if (expect_false (!ev_is_active (w)))
2566 return; 2569 return;
2567 2570
2568 { 2571 {
2569 int active = ((W)w)->active; 2572 int active = ev_active (w);
2573
2570 asyncs [active - 1] = asyncs [--asynccnt]; 2574 asyncs [active - 1] = asyncs [--asynccnt];
2571 ((W)asyncs [active - 1])->active = active; 2575 ev_active (asyncs [active - 1]) = active;
2572 } 2576 }
2573 2577
2574 ev_stop (EV_A_ (W)w); 2578 ev_stop (EV_A_ (W)w);
2575} 2579}
2576 2580

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines