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

Comparing libev/ev.c (file contents):
Revision 1.82 by root, Fri Nov 9 20:55:09 2007 UTC vs.
Revision 1.84 by root, Fri Nov 9 23:04:35 2007 UTC

518 518
519 heap [k] = w; 519 heap [k] = w;
520 ((W)heap [k])->active = k + 1; 520 ((W)heap [k])->active = k + 1;
521} 521}
522 522
523inline void
524adjustheap (WT *heap, int N, int k, ev_tstamp at)
525{
526 ev_tstamp old_at = heap [k]->at;
527 heap [k]->at = at;
528
529 if (old_at < at)
530 downheap (heap, N, k);
531 else
532 upheap (heap, k);
533}
534
523/*****************************************************************************/ 535/*****************************************************************************/
524 536
525typedef struct 537typedef struct
526{ 538{
527 WL head; 539 WL head;
751#endif 763#endif
752#if EV_USE_SELECT 764#if EV_USE_SELECT
753 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods); 765 if (!method && (methods & EVMETHOD_SELECT)) method = select_init (EV_A_ methods);
754#endif 766#endif
755 767
756 ev_watcher_init (&sigev, sigcb); 768 ev_init (&sigev, sigcb);
757 ev_set_priority (&sigev, EV_MAXPRI); 769 ev_set_priority (&sigev, EV_MAXPRI);
758 } 770 }
759} 771}
760 772
761void 773void
1321ev_timer_again (EV_P_ struct ev_timer *w) 1333ev_timer_again (EV_P_ struct ev_timer *w)
1322{ 1334{
1323 if (ev_is_active (w)) 1335 if (ev_is_active (w))
1324 { 1336 {
1325 if (w->repeat) 1337 if (w->repeat)
1326 {
1327 ((WT)w)->at = mn_now + w->repeat;
1328 downheap ((WT *)timers, timercnt, ((W)w)->active - 1); 1338 adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat);
1329 }
1330 else 1339 else
1331 ev_timer_stop (EV_A_ w); 1340 ev_timer_stop (EV_A_ w);
1332 } 1341 }
1333 else if (w->repeat) 1342 else if (w->repeat)
1334 ev_timer_start (EV_A_ w); 1343 ev_timer_start (EV_A_ w);
1376} 1385}
1377 1386
1378void 1387void
1379ev_periodic_again (EV_P_ struct ev_periodic *w) 1388ev_periodic_again (EV_P_ struct ev_periodic *w)
1380{ 1389{
1390 /* TODO: use adjustheap and recalculation */
1381 ev_periodic_stop (EV_A_ w); 1391 ev_periodic_stop (EV_A_ w);
1382 ev_periodic_start (EV_A_ w); 1392 ev_periodic_start (EV_A_ w);
1383} 1393}
1384 1394
1385void 1395void
1564 else 1574 else
1565 { 1575 {
1566 once->cb = cb; 1576 once->cb = cb;
1567 once->arg = arg; 1577 once->arg = arg;
1568 1578
1569 ev_watcher_init (&once->io, once_cb_io); 1579 ev_init (&once->io, once_cb_io);
1570 if (fd >= 0) 1580 if (fd >= 0)
1571 { 1581 {
1572 ev_io_set (&once->io, fd, events); 1582 ev_io_set (&once->io, fd, events);
1573 ev_io_start (EV_A_ &once->io); 1583 ev_io_start (EV_A_ &once->io);
1574 } 1584 }
1575 1585
1576 ev_watcher_init (&once->to, once_cb_to); 1586 ev_init (&once->to, once_cb_to);
1577 if (timeout >= 0.) 1587 if (timeout >= 0.)
1578 { 1588 {
1579 ev_timer_set (&once->to, timeout, 0.); 1589 ev_timer_set (&once->to, timeout, 0.);
1580 ev_timer_start (EV_A_ &once->to); 1590 ev_timer_start (EV_A_ &once->to);
1581 } 1591 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines