compat3 for ev++.h, default args c++

master
Marc Alexander Lehmann 12 years ago
parent 9e84d7ffd3
commit a9e4e2682d
  1. 2
      Changes
  2. 29
      ev++.h
  3. 18
      ev.h

@ -44,6 +44,8 @@ TODO: include ev_xyz_start in each example?
- define _DARWIN_UNLIMITED_SELECT. just so.
- use enum instead of #define for most constants.
- improve compatibility to older C++ compilers.
- ev_run/ev_default_loop/ev_break/ev_loop_new have now default
arguments when compiled as C++.
3.9 Thu Dec 31 07:59:59 CET 2009
- signalfd is no longer used by default and has to be requested

@ -64,7 +64,10 @@ namespace ev {
NONE = EV_NONE,
READ = EV_READ,
WRITE = EV_WRITE,
#if EV_COMPAT3
TIMEOUT = EV_TIMEOUT,
#endif
TIMER = EV_TIMER,
PERIODIC = EV_PERIODIC,
SIGNAL = EV_SIGNAL,
CHILD = EV_CHILD,
@ -95,14 +98,18 @@ namespace ev {
enum
{
#if EV_COMPAT3
NONBLOCK = EVLOOP_NONBLOCK,
ONESHOT = EVLOOP_ONESHOT
ONESHOT = EVLOOP_ONESHOT,
#endif
NOWAIT = EVRUN_NOWAIT,
ONCE = EVRUN_ONCE
};
enum how_t
{
ONE = EVUNLOOP_ONE,
ALL = EVUNLOOP_ALL
ONE = EVBREAK_ONE,
ALL = EVBREAK_ALL
};
struct bad_loop
@ -188,14 +195,26 @@ namespace ev {
}
#endif
#if EV_COMPAT3
void loop (int flags = 0)
{
ev_loop (EV_AX_ flags);
ev_run (EV_AX_ flags);
}
void unloop (how_t how = ONE) throw ()
{
ev_unloop (EV_AX_ how);
ev_break (EV_AX_ how);
}
#endif
void run (int flags = 0)
{
ev_run (EV_AX_ flags);
}
void break_loop (how_t how = ONE) throw ()
{
ev_break (EV_AX_ how);
}
void post_fork () throw ()

18
ev.h

@ -147,6 +147,12 @@ typedef double ev_tstamp;
# include <sys/stat.h>
#endif
#ifdef __cplusplus
# define EV_DEFARG(x) = x
#else
# define EV_DEFARG(x)
#endif
/* support multiple event loops? */
#if EV_MULTIPLICITY
struct ev_loop;
@ -194,7 +200,9 @@ enum {
EV__IOFDSET = 0x80, /* internal use only */
EV_IO = EV_READ, /* alias for type-detection */
EV_TIMER = 0x00000100, /* timer timed out */
#if EV_COMPAT3
EV_TIMEOUT = EV_TIMER, /* pre 4.0 API compatibility */
#endif
EV_PERIODIC = 0x00000200, /* periodic timer timed out */
EV_SIGNAL = 0x00000400, /* signal was received */
EV_CHILD = 0x00000800, /* child/pid had status change */
@ -513,7 +521,7 @@ ev_default_loop_uc (void)
/* the default loop is the only one that handles signals and child watchers */
/* you can call this as often as you like */
EV_INLINE struct ev_loop *
ev_default_loop (unsigned int flags)
ev_default_loop (unsigned int flags EV_DEFARG (0))
{
struct ev_loop *loop = ev_default_loop_uc ();
@ -528,7 +536,7 @@ ev_default_loop (unsigned int flags)
}
/* create and destroy alternative loops that don't handle signals */
struct ev_loop *ev_loop_new (unsigned int flags);
struct ev_loop *ev_loop_new (unsigned int flags EV_DEFARG (0));
void ev_loop_destroy (EV_P);
void ev_loop_fork (EV_P);
@ -536,7 +544,7 @@ ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after
#else
int ev_default_loop (unsigned int flags); /* returns true when successful */
int ev_default_loop (unsigned int flags EV_DEFARG (0)); /* returns true when successful */
EV_INLINE ev_tstamp
ev_now (void)
@ -593,8 +601,8 @@ enum {
};
#if EV_PROTOTYPES
void ev_run (EV_P_ int flags);
void ev_break (EV_P_ int how); /* set to 1 to break out of event loop, set to 2 to break out of all event loops */
void ev_run (EV_P_ int flags EV_DEFARG (0));
void ev_break (EV_P_ int how EV_DEFARG (EVBREAK_ONE)); /* break out of the loop */
/*
* ref/unref can be used to add or remove a refcount on the mainloop. every watcher

Loading…
Cancel
Save