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

Comparing libev/ev.c (file contents):
Revision 1.23 by root, Wed Oct 31 20:10:17 2007 UTC vs.
Revision 1.28 by root, Thu Nov 1 06:48:49 2007 UTC

130/*****************************************************************************/ 130/*****************************************************************************/
131 131
132typedef struct 132typedef struct
133{ 133{
134 struct ev_io *head; 134 struct ev_io *head;
135 unsigned char wev, rev; /* want, received event set */ 135 int events;
136} ANFD; 136} ANFD;
137 137
138static ANFD *anfds; 138static ANFD *anfds;
139static int anfdmax; 139static int anfdmax;
140 140
141static int *fdchanges;
142static int fdchangemax, fdchangecnt;
143
144static void 141static void
145anfds_init (ANFD *base, int count) 142anfds_init (ANFD *base, int count)
146{ 143{
147 while (count--) 144 while (count--)
148 { 145 {
149 base->head = 0; 146 base->head = 0;
150 base->wev = base->rev = EV_NONE; 147 base->events = EV_NONE;
151 ++base; 148 ++base;
152 } 149 }
153} 150}
154 151
155typedef struct 152typedef struct
172 pendings [pendingcnt - 1].events = events; 169 pendings [pendingcnt - 1].events = events;
173 } 170 }
174} 171}
175 172
176static void 173static void
174queue_events (W *events, int eventcnt, int type)
175{
176 int i;
177
178 for (i = 0; i < eventcnt; ++i)
179 event (events [i], type);
180}
181
182static void
177fd_event (int fd, int events) 183fd_event (int fd, int events)
178{ 184{
179 ANFD *anfd = anfds + fd; 185 ANFD *anfd = anfds + fd;
180 struct ev_io *w; 186 struct ev_io *w;
181 187
186 if (ev) 192 if (ev)
187 event ((W)w, ev); 193 event ((W)w, ev);
188 } 194 }
189} 195}
190 196
197/*****************************************************************************/
198
199static int *fdchanges;
200static int fdchangemax, fdchangecnt;
201
191static void 202static void
192queue_events (W *events, int eventcnt, int type) 203fd_reify (void)
193{ 204{
194 int i; 205 int i;
195 206
196 for (i = 0; i < eventcnt; ++i) 207 for (i = 0; i < fdchangecnt; ++i)
197 event (events [i], type); 208 {
209 int fd = fdchanges [i];
210 ANFD *anfd = anfds + fd;
211 struct ev_io *w;
212
213 int events = 0;
214
215 for (w = anfd->head; w; w = w->next)
216 events |= w->events;
217
218 anfd->events &= ~EV_REIFY;
219
220 if (anfd->events != events)
221 {
222 method_modify (fd, anfd->events, events);
223 anfd->events = events;
224 }
225 }
226
227 fdchangecnt = 0;
228}
229
230static void
231fd_change (int fd)
232{
233 if (anfds [fd].events & EV_REIFY)
234 return;
235
236 anfds [fd].events |= EV_REIFY;
237
238 ++fdchangecnt;
239 array_needsize (fdchanges, fdchangemax, fdchangecnt, );
240 fdchanges [fdchangecnt - 1] = fd;
198} 241}
199 242
200/* called on EBADF to verify fds */ 243/* called on EBADF to verify fds */
201static void 244static void
202fd_recheck () 245fd_recheck (void)
203{ 246{
204 int fd; 247 int fd;
205 248
206 for (fd = 0; fd < anfdmax; ++fd) 249 for (fd = 0; fd < anfdmax; ++fd)
207 if (anfds [fd].wev) 250 if (anfds [fd].events)
208 if (fcntl (fd, F_GETFD) == -1 && errno == EBADF) 251 if (fcntl (fd, F_GETFD) == -1 && errno == EBADF)
209 while (anfds [fd].head) 252 while (anfds [fd].head)
253 {
254 event ((W)anfds [fd].head, EV_ERROR);
210 evio_stop (anfds [fd].head); 255 ev_io_stop (anfds [fd].head);
256 }
211} 257}
212 258
213/*****************************************************************************/ 259/*****************************************************************************/
214 260
215static struct ev_timer **timers; 261static struct ev_timer **timers;
324 370
325 /* rather than sort out wether we really need nb, set it */ 371 /* rather than sort out wether we really need nb, set it */
326 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK); 372 fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
327 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK); 373 fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
328 374
329 evio_set (&sigev, sigpipe [0], EV_READ); 375 ev_io_set (&sigev, sigpipe [0], EV_READ);
330 evio_start (&sigev); 376 ev_io_start (&sigev);
331} 377}
332 378
333/*****************************************************************************/ 379/*****************************************************************************/
334 380
335static struct ev_idle **idles; 381static struct ev_idle **idles;
371# include "ev_epoll.c" 417# include "ev_epoll.c"
372#endif 418#endif
373#if HAVE_SELECT 419#if HAVE_SELECT
374# include "ev_select.c" 420# include "ev_select.c"
375#endif 421#endif
422
423int
424ev_version_major (void)
425{
426 return EV_VERSION_MAJOR;
427}
428
429int
430ev_version_minor (void)
431{
432 return EV_VERSION_MINOR;
433}
376 434
377int ev_init (int flags) 435int ev_init (int flags)
378{ 436{
379 if (!ev_method) 437 if (!ev_method)
380 { 438 {
401 if (ev_method == EVMETHOD_NONE) select_init (flags); 459 if (ev_method == EVMETHOD_NONE) select_init (flags);
402#endif 460#endif
403 461
404 if (ev_method) 462 if (ev_method)
405 { 463 {
406 evw_init (&sigev, sigcb); 464 ev_watcher_init (&sigev, sigcb);
407 siginit (); 465 siginit ();
408 466
409 evsignal_init (&childev, childcb, SIGCHLD); 467 ev_signal_init (&childev, childcb, SIGCHLD);
410 evsignal_start (&childev); 468 ev_signal_start (&childev);
411 } 469 }
412 } 470 }
413 471
414 return ev_method; 472 return ev_method;
415} 473}
416 474
417/*****************************************************************************/ 475/*****************************************************************************/
418 476
477void
419void ev_prefork (void) 478ev_prefork (void)
420{ 479{
421 /* nop */ 480 /* nop */
422} 481}
423 482
483void
424void ev_postfork_parent (void) 484ev_postfork_parent (void)
425{ 485{
426 /* nop */ 486 /* nop */
427} 487}
428 488
489void
429void ev_postfork_child (void) 490ev_postfork_child (void)
430{ 491{
431#if HAVE_EPOLL 492#if HAVE_EPOLL
432 if (ev_method == EVMETHOD_EPOLL) 493 if (ev_method == EVMETHOD_EPOLL)
433 epoll_postfork_child (); 494 epoll_postfork_child ();
434#endif 495#endif
435 496
436 evio_stop (&sigev); 497 ev_io_stop (&sigev);
437 close (sigpipe [0]); 498 close (sigpipe [0]);
438 close (sigpipe [1]); 499 close (sigpipe [1]);
439 pipe (sigpipe); 500 pipe (sigpipe);
440 siginit (); 501 siginit ();
441} 502}
442 503
443/*****************************************************************************/ 504/*****************************************************************************/
444 505
445static void 506static void
446fd_reify (void)
447{
448 int i;
449
450 for (i = 0; i < fdchangecnt; ++i)
451 {
452 int fd = fdchanges [i];
453 ANFD *anfd = anfds + fd;
454 struct ev_io *w;
455
456 int wev = 0;
457
458 for (w = anfd->head; w; w = w->next)
459 wev |= w->events;
460
461 if (anfd->wev != wev)
462 {
463 method_modify (fd, anfd->wev, wev);
464 anfd->wev = wev;
465 }
466 }
467
468 fdchangecnt = 0;
469}
470
471static void
472call_pending () 507call_pending (void)
473{ 508{
474 while (pendingcnt) 509 while (pendingcnt)
475 { 510 {
476 ANPENDING *p = pendings + --pendingcnt; 511 ANPENDING *p = pendings + --pendingcnt;
477 512
482 } 517 }
483 } 518 }
484} 519}
485 520
486static void 521static void
487timers_reify () 522timers_reify (void)
488{ 523{
489 while (timercnt && timers [0]->at <= now) 524 while (timercnt && timers [0]->at <= now)
490 { 525 {
491 struct ev_timer *w = timers [0]; 526 struct ev_timer *w = timers [0];
492 527
498 w->at = now + w->repeat; 533 w->at = now + w->repeat;
499 assert (("timer timeout in the past, negative repeat?", w->at > now)); 534 assert (("timer timeout in the past, negative repeat?", w->at > now));
500 downheap ((WT *)timers, timercnt, 0); 535 downheap ((WT *)timers, timercnt, 0);
501 } 536 }
502 else 537 else
503 evtimer_stop (w); /* nonrepeating: stop timer */ 538 ev_timer_stop (w); /* nonrepeating: stop timer */
504 } 539 }
505} 540}
506 541
507static void 542static void
508periodics_reify () 543periodics_reify (void)
509{ 544{
510 while (periodiccnt && periodics [0]->at <= ev_now) 545 while (periodiccnt && periodics [0]->at <= ev_now)
511 { 546 {
512 struct ev_periodic *w = periodics [0]; 547 struct ev_periodic *w = periodics [0];
513 548
517 w->at += floor ((ev_now - w->at) / w->interval + 1.) * w->interval; 552 w->at += floor ((ev_now - w->at) / w->interval + 1.) * w->interval;
518 assert (("periodic timeout in the past, negative interval?", w->at > ev_now)); 553 assert (("periodic timeout in the past, negative interval?", w->at > ev_now));
519 downheap ((WT *)periodics, periodiccnt, 0); 554 downheap ((WT *)periodics, periodiccnt, 0);
520 } 555 }
521 else 556 else
522 evperiodic_stop (w); /* nonrepeating: stop timer */ 557 ev_periodic_stop (w); /* nonrepeating: stop timer */
523 558
524 event ((W)w, EV_TIMEOUT); 559 event ((W)w, EV_TIMEOUT);
525 } 560 }
526} 561}
527 562
539 { 574 {
540 ev_tstamp diff = ceil ((ev_now - w->at) / w->interval) * w->interval; 575 ev_tstamp diff = ceil ((ev_now - w->at) / w->interval) * w->interval;
541 576
542 if (fabs (diff) >= 1e-4) 577 if (fabs (diff) >= 1e-4)
543 { 578 {
544 evperiodic_stop (w); 579 ev_periodic_stop (w);
545 evperiodic_start (w); 580 ev_periodic_start (w);
546 581
547 i = 0; /* restart loop, inefficient, but time jumps should be rare */ 582 i = 0; /* restart loop, inefficient, but time jumps should be rare */
548 } 583 }
549 } 584 }
550 } 585 }
551} 586}
552 587
553static void 588static void
554time_update () 589time_update (void)
555{ 590{
556 int i; 591 int i;
557 592
558 ev_now = ev_time (); 593 ev_now = ev_time ();
559 594
593int ev_loop_done; 628int ev_loop_done;
594 629
595void ev_loop (int flags) 630void ev_loop (int flags)
596{ 631{
597 double block; 632 double block;
598 ev_loop_done = flags & EVLOOP_ONESHOT ? 1 : 0; 633 ev_loop_done = flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK) ? 1 : 0;
599 634
600 do 635 do
601 { 636 {
602 /* queue check watchers (and execute them) */ 637 /* queue check watchers (and execute them) */
603 if (preparecnt) 638 if (preparecnt)
708} 743}
709 744
710/*****************************************************************************/ 745/*****************************************************************************/
711 746
712void 747void
713evio_start (struct ev_io *w) 748ev_io_start (struct ev_io *w)
714{ 749{
715 if (ev_is_active (w)) 750 if (ev_is_active (w))
716 return; 751 return;
717 752
718 int fd = w->fd; 753 int fd = w->fd;
719 754
720 ev_start ((W)w, 1); 755 ev_start ((W)w, 1);
721 array_needsize (anfds, anfdmax, fd + 1, anfds_init); 756 array_needsize (anfds, anfdmax, fd + 1, anfds_init);
722 wlist_add ((WL *)&anfds[fd].head, (WL)w); 757 wlist_add ((WL *)&anfds[fd].head, (WL)w);
723 758
724 ++fdchangecnt; 759 fd_change (fd);
725 array_needsize (fdchanges, fdchangemax, fdchangecnt, );
726 fdchanges [fdchangecnt - 1] = fd;
727} 760}
728 761
729void 762void
730evio_stop (struct ev_io *w) 763ev_io_stop (struct ev_io *w)
731{ 764{
732 ev_clear ((W)w); 765 ev_clear ((W)w);
733 if (!ev_is_active (w)) 766 if (!ev_is_active (w))
734 return; 767 return;
735 768
736 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 769 wlist_del ((WL *)&anfds[w->fd].head, (WL)w);
737 ev_stop ((W)w); 770 ev_stop ((W)w);
738 771
739 ++fdchangecnt; 772 fd_change (w->fd);
740 array_needsize (fdchanges, fdchangemax, fdchangecnt, );
741 fdchanges [fdchangecnt - 1] = w->fd;
742} 773}
743 774
744void 775void
745evtimer_start (struct ev_timer *w) 776ev_timer_start (struct ev_timer *w)
746{ 777{
747 if (ev_is_active (w)) 778 if (ev_is_active (w))
748 return; 779 return;
749 780
750 w->at += now; 781 w->at += now;
756 timers [timercnt - 1] = w; 787 timers [timercnt - 1] = w;
757 upheap ((WT *)timers, timercnt - 1); 788 upheap ((WT *)timers, timercnt - 1);
758} 789}
759 790
760void 791void
761evtimer_stop (struct ev_timer *w) 792ev_timer_stop (struct ev_timer *w)
762{ 793{
763 ev_clear ((W)w); 794 ev_clear ((W)w);
764 if (!ev_is_active (w)) 795 if (!ev_is_active (w))
765 return; 796 return;
766 797
774 805
775 ev_stop ((W)w); 806 ev_stop ((W)w);
776} 807}
777 808
778void 809void
779evtimer_again (struct ev_timer *w) 810ev_timer_again (struct ev_timer *w)
780{ 811{
781 if (ev_is_active (w)) 812 if (ev_is_active (w))
782 { 813 {
783 if (w->repeat) 814 if (w->repeat)
784 { 815 {
785 w->at = now + w->repeat; 816 w->at = now + w->repeat;
786 downheap ((WT *)timers, timercnt, w->active - 1); 817 downheap ((WT *)timers, timercnt, w->active - 1);
787 } 818 }
788 else 819 else
789 evtimer_stop (w); 820 ev_timer_stop (w);
790 } 821 }
791 else if (w->repeat) 822 else if (w->repeat)
792 evtimer_start (w); 823 ev_timer_start (w);
793} 824}
794 825
795void 826void
796evperiodic_start (struct ev_periodic *w) 827ev_periodic_start (struct ev_periodic *w)
797{ 828{
798 if (ev_is_active (w)) 829 if (ev_is_active (w))
799 return; 830 return;
800 831
801 assert (("periodic interval value less than zero not allowed", w->interval >= 0.)); 832 assert (("periodic interval value less than zero not allowed", w->interval >= 0.));
809 periodics [periodiccnt - 1] = w; 840 periodics [periodiccnt - 1] = w;
810 upheap ((WT *)periodics, periodiccnt - 1); 841 upheap ((WT *)periodics, periodiccnt - 1);
811} 842}
812 843
813void 844void
814evperiodic_stop (struct ev_periodic *w) 845ev_periodic_stop (struct ev_periodic *w)
815{ 846{
816 ev_clear ((W)w); 847 ev_clear ((W)w);
817 if (!ev_is_active (w)) 848 if (!ev_is_active (w))
818 return; 849 return;
819 850
825 856
826 ev_stop ((W)w); 857 ev_stop ((W)w);
827} 858}
828 859
829void 860void
830evsignal_start (struct ev_signal *w) 861ev_signal_start (struct ev_signal *w)
831{ 862{
832 if (ev_is_active (w)) 863 if (ev_is_active (w))
833 return; 864 return;
834 865
835 ev_start ((W)w, 1); 866 ev_start ((W)w, 1);
845 sigaction (w->signum, &sa, 0); 876 sigaction (w->signum, &sa, 0);
846 } 877 }
847} 878}
848 879
849void 880void
850evsignal_stop (struct ev_signal *w) 881ev_signal_stop (struct ev_signal *w)
851{ 882{
852 ev_clear ((W)w); 883 ev_clear ((W)w);
853 if (!ev_is_active (w)) 884 if (!ev_is_active (w))
854 return; 885 return;
855 886
858 889
859 if (!signals [w->signum - 1].head) 890 if (!signals [w->signum - 1].head)
860 signal (w->signum, SIG_DFL); 891 signal (w->signum, SIG_DFL);
861} 892}
862 893
894void
863void evidle_start (struct ev_idle *w) 895ev_idle_start (struct ev_idle *w)
864{ 896{
865 if (ev_is_active (w)) 897 if (ev_is_active (w))
866 return; 898 return;
867 899
868 ev_start ((W)w, ++idlecnt); 900 ev_start ((W)w, ++idlecnt);
869 array_needsize (idles, idlemax, idlecnt, ); 901 array_needsize (idles, idlemax, idlecnt, );
870 idles [idlecnt - 1] = w; 902 idles [idlecnt - 1] = w;
871} 903}
872 904
905void
873void evidle_stop (struct ev_idle *w) 906ev_idle_stop (struct ev_idle *w)
874{ 907{
875 ev_clear ((W)w); 908 ev_clear ((W)w);
876 if (ev_is_active (w)) 909 if (ev_is_active (w))
877 return; 910 return;
878 911
879 idles [w->active - 1] = idles [--idlecnt]; 912 idles [w->active - 1] = idles [--idlecnt];
880 ev_stop ((W)w); 913 ev_stop ((W)w);
881} 914}
882 915
916void
883void evprepare_start (struct ev_prepare *w) 917ev_prepare_start (struct ev_prepare *w)
884{ 918{
885 if (ev_is_active (w)) 919 if (ev_is_active (w))
886 return; 920 return;
887 921
888 ev_start ((W)w, ++preparecnt); 922 ev_start ((W)w, ++preparecnt);
889 array_needsize (prepares, preparemax, preparecnt, ); 923 array_needsize (prepares, preparemax, preparecnt, );
890 prepares [preparecnt - 1] = w; 924 prepares [preparecnt - 1] = w;
891} 925}
892 926
927void
893void evprepare_stop (struct ev_prepare *w) 928ev_prepare_stop (struct ev_prepare *w)
894{ 929{
895 ev_clear ((W)w); 930 ev_clear ((W)w);
896 if (ev_is_active (w)) 931 if (ev_is_active (w))
897 return; 932 return;
898 933
899 prepares [w->active - 1] = prepares [--preparecnt]; 934 prepares [w->active - 1] = prepares [--preparecnt];
900 ev_stop ((W)w); 935 ev_stop ((W)w);
901} 936}
902 937
938void
903void evcheck_start (struct ev_check *w) 939ev_check_start (struct ev_check *w)
904{ 940{
905 if (ev_is_active (w)) 941 if (ev_is_active (w))
906 return; 942 return;
907 943
908 ev_start ((W)w, ++checkcnt); 944 ev_start ((W)w, ++checkcnt);
909 array_needsize (checks, checkmax, checkcnt, ); 945 array_needsize (checks, checkmax, checkcnt, );
910 checks [checkcnt - 1] = w; 946 checks [checkcnt - 1] = w;
911} 947}
912 948
949void
913void evcheck_stop (struct ev_check *w) 950ev_check_stop (struct ev_check *w)
914{ 951{
915 ev_clear ((W)w); 952 ev_clear ((W)w);
916 if (ev_is_active (w)) 953 if (ev_is_active (w))
917 return; 954 return;
918 955
919 checks [w->active - 1] = checks [--checkcnt]; 956 checks [w->active - 1] = checks [--checkcnt];
920 ev_stop ((W)w); 957 ev_stop ((W)w);
921} 958}
922 959
960void
923void evchild_start (struct ev_child *w) 961ev_child_start (struct ev_child *w)
924{ 962{
925 if (ev_is_active (w)) 963 if (ev_is_active (w))
926 return; 964 return;
927 965
928 ev_start ((W)w, 1); 966 ev_start ((W)w, 1);
929 wlist_add ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w); 967 wlist_add ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
930} 968}
931 969
970void
932void evchild_stop (struct ev_child *w) 971ev_child_stop (struct ev_child *w)
933{ 972{
934 ev_clear ((W)w); 973 ev_clear ((W)w);
935 if (ev_is_active (w)) 974 if (ev_is_active (w))
936 return; 975 return;
937 976
953once_cb (struct ev_once *once, int revents) 992once_cb (struct ev_once *once, int revents)
954{ 993{
955 void (*cb)(int revents, void *arg) = once->cb; 994 void (*cb)(int revents, void *arg) = once->cb;
956 void *arg = once->arg; 995 void *arg = once->arg;
957 996
958 evio_stop (&once->io); 997 ev_io_stop (&once->io);
959 evtimer_stop (&once->to); 998 ev_timer_stop (&once->to);
960 free (once); 999 free (once);
961 1000
962 cb (revents, arg); 1001 cb (revents, arg);
963} 1002}
964 1003
984 else 1023 else
985 { 1024 {
986 once->cb = cb; 1025 once->cb = cb;
987 once->arg = arg; 1026 once->arg = arg;
988 1027
989 evw_init (&once->io, once_cb_io); 1028 ev_watcher_init (&once->io, once_cb_io);
990 1029
991 if (fd >= 0) 1030 if (fd >= 0)
992 { 1031 {
993 evio_set (&once->io, fd, events); 1032 ev_io_set (&once->io, fd, events);
994 evio_start (&once->io); 1033 ev_io_start (&once->io);
995 } 1034 }
996 1035
997 evw_init (&once->to, once_cb_to); 1036 ev_watcher_init (&once->to, once_cb_to);
998 1037
999 if (timeout >= 0.) 1038 if (timeout >= 0.)
1000 { 1039 {
1001 evtimer_set (&once->to, timeout, 0.); 1040 ev_timer_set (&once->to, timeout, 0.);
1002 evtimer_start (&once->to); 1041 ev_timer_start (&once->to);
1003 } 1042 }
1004 } 1043 }
1005} 1044}
1006 1045
1007/*****************************************************************************/ 1046/*****************************************************************************/
1018 1057
1019static void 1058static void
1020ocb (struct ev_timer *w, int revents) 1059ocb (struct ev_timer *w, int revents)
1021{ 1060{
1022 //fprintf (stderr, "timer %f,%f (%x) (%f) d%p\n", w->at, w->repeat, revents, w->at - ev_time (), w->data); 1061 //fprintf (stderr, "timer %f,%f (%x) (%f) d%p\n", w->at, w->repeat, revents, w->at - ev_time (), w->data);
1023 evtimer_stop (w); 1062 ev_timer_stop (w);
1024 evtimer_start (w); 1063 ev_timer_start (w);
1025} 1064}
1026 1065
1027static void 1066static void
1028scb (struct ev_signal *w, int revents) 1067scb (struct ev_signal *w, int revents)
1029{ 1068{
1030 fprintf (stderr, "signal %x,%d\n", revents, w->signum); 1069 fprintf (stderr, "signal %x,%d\n", revents, w->signum);
1031 evio_stop (&wio); 1070 ev_io_stop (&wio);
1032 evio_start (&wio); 1071 ev_io_start (&wio);
1033} 1072}
1034 1073
1035static void 1074static void
1036gcb (struct ev_signal *w, int revents) 1075gcb (struct ev_signal *w, int revents)
1037{ 1076{
1041 1080
1042int main (void) 1081int main (void)
1043{ 1082{
1044 ev_init (0); 1083 ev_init (0);
1045 1084
1046 evio_init (&wio, sin_cb, 0, EV_READ); 1085 ev_io_init (&wio, sin_cb, 0, EV_READ);
1047 evio_start (&wio); 1086 ev_io_start (&wio);
1048 1087
1049 struct ev_timer t[10000]; 1088 struct ev_timer t[10000];
1050 1089
1051#if 0 1090#if 0
1052 int i; 1091 int i;
1053 for (i = 0; i < 10000; ++i) 1092 for (i = 0; i < 10000; ++i)
1054 { 1093 {
1055 struct ev_timer *w = t + i; 1094 struct ev_timer *w = t + i;
1056 evw_init (w, ocb, i); 1095 ev_watcher_init (w, ocb, i);
1057 evtimer_init_abs (w, ocb, drand48 (), 0.99775533); 1096 ev_timer_init_abs (w, ocb, drand48 (), 0.99775533);
1058 evtimer_start (w); 1097 ev_timer_start (w);
1059 if (drand48 () < 0.5) 1098 if (drand48 () < 0.5)
1060 evtimer_stop (w); 1099 ev_timer_stop (w);
1061 } 1100 }
1062#endif 1101#endif
1063 1102
1064 struct ev_timer t1; 1103 struct ev_timer t1;
1065 evtimer_init (&t1, ocb, 5, 10); 1104 ev_timer_init (&t1, ocb, 5, 10);
1066 evtimer_start (&t1); 1105 ev_timer_start (&t1);
1067 1106
1068 struct ev_signal sig; 1107 struct ev_signal sig;
1069 evsignal_init (&sig, scb, SIGQUIT); 1108 ev_signal_init (&sig, scb, SIGQUIT);
1070 evsignal_start (&sig); 1109 ev_signal_start (&sig);
1071 1110
1072 struct ev_check cw; 1111 struct ev_check cw;
1073 evcheck_init (&cw, gcb); 1112 ev_check_init (&cw, gcb);
1074 evcheck_start (&cw); 1113 ev_check_start (&cw);
1075 1114
1076 struct ev_idle iw; 1115 struct ev_idle iw;
1077 evidle_init (&iw, gcb); 1116 ev_idle_init (&iw, gcb);
1078 evidle_start (&iw); 1117 ev_idle_start (&iw);
1079 1118
1080 ev_loop (0); 1119 ev_loop (0);
1081 1120
1082 return 0; 1121 return 0;
1083} 1122}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines