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

Comparing libev/ev++.h (file contents):
Revision 1.44 by root, Wed Dec 3 15:23:44 2008 UTC vs.
Revision 1.53 by root, Thu Oct 21 14:50:58 2010 UTC

1/* 1/*
2 * libev simple C++ wrapper classes 2 * libev simple C++ wrapper classes
3 * 3 *
4 * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2010 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
74 PREPARE = EV_PREPARE, 74 PREPARE = EV_PREPARE,
75 FORK = EV_FORK, 75 FORK = EV_FORK,
76 ASYNC = EV_ASYNC, 76 ASYNC = EV_ASYNC,
77 EMBED = EV_EMBED, 77 EMBED = EV_EMBED,
78# undef ERROR // some systems stupidly #define ERROR 78# undef ERROR // some systems stupidly #define ERROR
79 ERROR = EV_ERROR, 79 ERROR = EV_ERROR
80 }; 80 };
81 81
82 enum 82 enum
83 { 83 {
84 AUTO = EVFLAG_AUTO, 84 AUTO = EVFLAG_AUTO,
205#else 205#else
206 ev_default_fork (); 206 ev_default_fork ();
207#endif 207#endif
208 } 208 }
209 209
210 unsigned int count () const throw ()
211 {
212 return ev_loop_count (EV_AX);
213 }
214
215 unsigned int backend () const throw () 210 unsigned int backend () const throw ()
216 { 211 {
217 return ev_backend (EV_AX); 212 return ev_backend (EV_AX);
218 } 213 }
219 214
230 void unref () throw () 225 void unref () throw ()
231 { 226 {
232 ev_unref (EV_AX); 227 ev_unref (EV_AX);
233 } 228 }
234 229
230#if EV_FEATURE_API
231 unsigned int iteration () const throw ()
232 {
233 return ev_iteration (EV_AX);
234 }
235
236 unsigned int depth () const throw ()
237 {
238 return ev_depth (EV_AX);
239 }
240
235 void set_io_collect_interval (tstamp interval) throw () 241 void set_io_collect_interval (tstamp interval) throw ()
236 { 242 {
237 ev_set_io_collect_interval (EV_AX_ interval); 243 ev_set_io_collect_interval (EV_AX_ interval);
238 } 244 }
239 245
240 void set_timeout_collect_interval (tstamp interval) throw () 246 void set_timeout_collect_interval (tstamp interval) throw ()
241 { 247 {
242 ev_set_timeout_collect_interval (EV_AX_ interval); 248 ev_set_timeout_collect_interval (EV_AX_ interval);
243 } 249 }
250#endif
244 251
245 // function callback 252 // function callback
246 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw () 253 void once (int fd, int events, tstamp timeout, void (*cb)(int, void *), void *arg = 0) throw ()
247 { 254 {
248 ev_once (EV_AX_ fd, events, timeout, cb, arg); 255 ev_once (EV_AX_ fd, events, timeout, cb, arg);
406 struct base : ev_watcher 413 struct base : ev_watcher
407 { 414 {
408 #if EV_MULTIPLICITY 415 #if EV_MULTIPLICITY
409 EV_PX; 416 EV_PX;
410 417
418 // loop set
411 void set (EV_P) throw () 419 void set (EV_P) throw ()
412 { 420 {
413 this->EV_A = EV_A; 421 this->EV_A = EV_A;
414 } 422 }
415 #endif 423 #endif
471 } 479 }
472 480
473 template<class K, void (K::*method)()> 481 template<class K, void (K::*method)()>
474 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents) 482 static void method_noargs_thunk (EV_P_ ev_watcher *w, int revents)
475 { 483 {
476 static_cast<K *>(w->data)->*method 484 (static_cast<K *>(w->data)->*method)
477 (); 485 ();
478 } 486 }
479 487
480 void operator ()(int events = EV_UNDEF) 488 void operator ()(int events = EV_UNDEF)
481 { 489 {
635 643
636 void again () throw () 644 void again () throw ()
637 { 645 {
638 ev_timer_again (EV_A_ static_cast<ev_timer *>(this)); 646 ev_timer_again (EV_A_ static_cast<ev_timer *>(this));
639 } 647 }
648
649 ev_tstamp remaining ()
650 {
651 return ev_timer_remaining (EV_A_ static_cast<ev_timer *>(this));
652 }
640 EV_END_WATCHER (timer, timer) 653 EV_END_WATCHER (timer, timer)
641 654
642 #if EV_PERIODIC_ENABLE 655 #if EV_PERIODIC_ENABLE
643 EV_BEGIN_WATCHER (periodic, periodic) 656 EV_BEGIN_WATCHER (periodic, periodic)
644 void set (ev_tstamp at, ev_tstamp interval = 0.) throw () 657 void set (ev_tstamp at, ev_tstamp interval = 0.) throw ()
660 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this)); 673 ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
661 } 674 }
662 EV_END_WATCHER (periodic, periodic) 675 EV_END_WATCHER (periodic, periodic)
663 #endif 676 #endif
664 677
678 #if EV_SIGNAL_ENABLE
665 EV_BEGIN_WATCHER (sig, signal) 679 EV_BEGIN_WATCHER (sig, signal)
666 void set (int signum) throw () 680 void set (int signum) throw ()
667 { 681 {
668 int active = is_active (); 682 int active = is_active ();
669 if (active) stop (); 683 if (active) stop ();
675 { 689 {
676 set (signum); 690 set (signum);
677 start (); 691 start ();
678 } 692 }
679 EV_END_WATCHER (sig, signal) 693 EV_END_WATCHER (sig, signal)
694 #endif
680 695
696 #if EV_CHILD_ENABLE
681 EV_BEGIN_WATCHER (child, child) 697 EV_BEGIN_WATCHER (child, child)
682 void set (int pid, int trace = 0) throw () 698 void set (int pid, int trace = 0) throw ()
683 { 699 {
684 int active = is_active (); 700 int active = is_active ();
685 if (active) stop (); 701 if (active) stop ();
691 { 707 {
692 set (pid, trace); 708 set (pid, trace);
693 start (); 709 start ();
694 } 710 }
695 EV_END_WATCHER (child, child) 711 EV_END_WATCHER (child, child)
712 #endif
696 713
697 #if EV_STAT_ENABLE 714 #if EV_STAT_ENABLE
698 EV_BEGIN_WATCHER (stat, stat) 715 EV_BEGIN_WATCHER (stat, stat)
699 void set (const char *path, ev_tstamp interval = 0.) throw () 716 void set (const char *path, ev_tstamp interval = 0.) throw ()
700 { 717 {
716 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this)); 733 ev_stat_stat (EV_A_ static_cast<ev_stat *>(this));
717 } 734 }
718 EV_END_WATCHER (stat, stat) 735 EV_END_WATCHER (stat, stat)
719 #endif 736 #endif
720 737
738 #if EV_IDLE_ENABLE
721 EV_BEGIN_WATCHER (idle, idle) 739 EV_BEGIN_WATCHER (idle, idle)
722 void set () throw () { } 740 void set () throw () { }
723 EV_END_WATCHER (idle, idle) 741 EV_END_WATCHER (idle, idle)
742 #endif
724 743
744 #if EV_PREPARE_ENABLE
725 EV_BEGIN_WATCHER (prepare, prepare) 745 EV_BEGIN_WATCHER (prepare, prepare)
726 void set () throw () { } 746 void set () throw () { }
727 EV_END_WATCHER (prepare, prepare) 747 EV_END_WATCHER (prepare, prepare)
748 #endif
728 749
750 #if EV_CHECK_ENABLE
729 EV_BEGIN_WATCHER (check, check) 751 EV_BEGIN_WATCHER (check, check)
730 void set () throw () { } 752 void set () throw () { }
731 EV_END_WATCHER (check, check) 753 EV_END_WATCHER (check, check)
754 #endif
732 755
733 #if EV_EMBED_ENABLE 756 #if EV_EMBED_ENABLE
734 EV_BEGIN_WATCHER (embed, embed) 757 EV_BEGIN_WATCHER (embed, embed)
735 void set (struct ev_loop *embedded_loop) throw () 758 void set (struct ev_loop *embedded_loop) throw ()
736 { 759 {
759 EV_END_WATCHER (fork, fork) 782 EV_END_WATCHER (fork, fork)
760 #endif 783 #endif
761 784
762 #if EV_ASYNC_ENABLE 785 #if EV_ASYNC_ENABLE
763 EV_BEGIN_WATCHER (async, async) 786 EV_BEGIN_WATCHER (async, async)
764 void set () throw () { }
765
766 void send () throw () 787 void send () throw ()
767 { 788 {
768 ev_async_send (EV_A_ static_cast<ev_async *>(this)); 789 ev_async_send (EV_A_ static_cast<ev_async *>(this));
769 } 790 }
770 791

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines