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

Comparing libev/ev.c (file contents):
Revision 1.150 by root, Tue Nov 27 19:41:52 2007 UTC vs.
Revision 1.151 by root, Tue Nov 27 19:59:08 2007 UTC

852ev_backend (EV_P) 852ev_backend (EV_P)
853{ 853{
854 return backend; 854 return backend;
855} 855}
856 856
857static void 857static void noinline
858loop_init (EV_P_ unsigned int flags) 858loop_init (EV_P_ unsigned int flags)
859{ 859{
860 if (!backend) 860 if (!backend)
861 { 861 {
862#if EV_USE_MONOTONIC 862#if EV_USE_MONOTONIC
900 ev_init (&sigev, sigcb); 900 ev_init (&sigev, sigcb);
901 ev_set_priority (&sigev, EV_MAXPRI); 901 ev_set_priority (&sigev, EV_MAXPRI);
902 } 902 }
903} 903}
904 904
905static void 905static void noinline
906loop_destroy (EV_P) 906loop_destroy (EV_P)
907{ 907{
908 int i; 908 int i;
909 909
910#if EV_USE_PORT 910#if EV_USE_PORT
937 array_free (check, EMPTY0); 937 array_free (check, EMPTY0);
938 938
939 backend = 0; 939 backend = 0;
940} 940}
941 941
942static void 942void inline_size
943loop_fork (EV_P) 943loop_fork (EV_P)
944{ 944{
945#if EV_USE_PORT 945#if EV_USE_PORT
946 if (backend == EVBACKEND_PORT ) port_fork (EV_A); 946 if (backend == EVBACKEND_PORT ) port_fork (EV_A);
947#endif 947#endif
1097 { 1097 {
1098 ANPENDING *p = pendings [pri] + --pendingcnt [pri]; 1098 ANPENDING *p = pendings [pri] + --pendingcnt [pri];
1099 1099
1100 if (expect_true (p->w)) 1100 if (expect_true (p->w))
1101 { 1101 {
1102 assert (("non-pending watcher on pending list", p->w->pending)); 1102 /*assert (("non-pending watcher on pending list", p->w->pending));*/
1103 1103
1104 p->w->pending = 0; 1104 p->w->pending = 0;
1105 EV_CB_INVOKE (p->w, p->events); 1105 EV_CB_INVOKE (p->w, p->events);
1106 } 1106 }
1107 } 1107 }
1112{ 1112{
1113 while (timercnt && ((WT)timers [0])->at <= mn_now) 1113 while (timercnt && ((WT)timers [0])->at <= mn_now)
1114 { 1114 {
1115 ev_timer *w = timers [0]; 1115 ev_timer *w = timers [0];
1116 1116
1117 assert (("inactive timer on timer heap detected", ev_is_active (w))); 1117 /*assert (("inactive timer on timer heap detected", ev_is_active (w)));*/
1118 1118
1119 /* first reschedule or stop timer */ 1119 /* first reschedule or stop timer */
1120 if (w->repeat) 1120 if (w->repeat)
1121 { 1121 {
1122 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 1122 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
1140{ 1140{
1141 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now) 1141 while (periodiccnt && ((WT)periodics [0])->at <= ev_rt_now)
1142 { 1142 {
1143 ev_periodic *w = periodics [0]; 1143 ev_periodic *w = periodics [0];
1144 1144
1145 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 1145 /*assert (("inactive timer on periodic heap detected", ev_is_active (w)));*/
1146 1146
1147 /* first reschedule or stop timer */ 1147 /* first reschedule or stop timer */
1148 if (w->reschedule_cb) 1148 if (w->reschedule_cb)
1149 { 1149 {
1150 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001); 1150 ((WT)w)->at = w->reschedule_cb (w, ev_rt_now + 0.0001);
1482 ev_start (EV_A_ (W)w, ++timercnt); 1482 ev_start (EV_A_ (W)w, ++timercnt);
1483 array_needsize (ev_timer *, timers, timermax, timercnt, EMPTY2); 1483 array_needsize (ev_timer *, timers, timermax, timercnt, EMPTY2);
1484 timers [timercnt - 1] = w; 1484 timers [timercnt - 1] = w;
1485 upheap ((WT *)timers, timercnt - 1); 1485 upheap ((WT *)timers, timercnt - 1);
1486 1486
1487 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1487 /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/
1488} 1488}
1489 1489
1490void 1490void
1491ev_timer_stop (EV_P_ ev_timer *w) 1491ev_timer_stop (EV_P_ ev_timer *w)
1492{ 1492{
1494 if (expect_false (!ev_is_active (w))) 1494 if (expect_false (!ev_is_active (w)))
1495 return; 1495 return;
1496 1496
1497 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1497 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1498 1498
1499 {
1500 int active = ((W)w)->active;
1501
1499 if (expect_true (((W)w)->active < timercnt--)) 1502 if (expect_true (--active < --timercnt))
1500 { 1503 {
1501 timers [((W)w)->active - 1] = timers [timercnt]; 1504 timers [active] = timers [timercnt];
1502 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1505 adjustheap ((WT *)timers, timercnt, active);
1503 } 1506 }
1507 }
1504 1508
1505 ((WT)w)->at -= mn_now; 1509 ((WT)w)->at -= mn_now;
1506 1510
1507 ev_stop (EV_A_ (W)w); 1511 ev_stop (EV_A_ (W)w);
1508} 1512}
1546 ev_start (EV_A_ (W)w, ++periodiccnt); 1550 ev_start (EV_A_ (W)w, ++periodiccnt);
1547 array_needsize (ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2); 1551 array_needsize (ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2);
1548 periodics [periodiccnt - 1] = w; 1552 periodics [periodiccnt - 1] = w;
1549 upheap ((WT *)periodics, periodiccnt - 1); 1553 upheap ((WT *)periodics, periodiccnt - 1);
1550 1554
1551 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1555 /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/
1552} 1556}
1553 1557
1554void 1558void
1555ev_periodic_stop (EV_P_ ev_periodic *w) 1559ev_periodic_stop (EV_P_ ev_periodic *w)
1556{ 1560{
1558 if (expect_false (!ev_is_active (w))) 1562 if (expect_false (!ev_is_active (w)))
1559 return; 1563 return;
1560 1564
1561 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1565 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1562 1566
1567 {
1568 int active = ((W)w)->active;
1569
1563 if (expect_true (((W)w)->active < periodiccnt--)) 1570 if (expect_true (--active < --periodiccnt))
1564 { 1571 {
1565 periodics [((W)w)->active - 1] = periodics [periodiccnt]; 1572 periodics [active] = periodics [periodiccnt];
1566 adjustheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1); 1573 adjustheap ((WT *)periodics, periodiccnt, active);
1567 } 1574 }
1575 }
1568 1576
1569 ev_stop (EV_A_ (W)w); 1577 ev_stop (EV_A_ (W)w);
1570} 1578}
1571 1579
1572void 1580void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines