summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-11-11 01:07:35 +0000
committerroot <root>2007-11-11 01:07:35 +0000
commit8eaf72b24298b3c7c6e33812b1410b1ee3bb33c6 (patch)
tree8ccd4b8fd65a550857a37c8d625b272ed1d504b8
parent6778edc72c8101697c478c40f104fe75c97e336e (diff)
fix bug
-rw-r--r--README.embed31
-rw-r--r--ev++.C2
-rw-r--r--ev++.h7
-rw-r--r--ev.c14
-rw-r--r--ev.h6
-rw-r--r--ev_vars.h2
-rw-r--r--ev_wrap.h1
7 files changed, 49 insertions, 14 deletions
diff --git a/README.embed b/README.embed
index df5491a..925c13e 100644
--- a/README.embed
+++ b/README.embed
@@ -149,19 +149,6 @@ PREPROCESSOR SYMBOLS
Similarly to EV_H, this macro cna be used to override event.c's idea
of how the event.h header can be found.
- EV_COMMON
-
- By default, all watchers have a "void *data" member. By redefining
- this macro to a something else you can include more and other types
- of members. You have to define it each time you include one of the
- files, though, and it must be identical each time.
-
- For example, the perl EV module uses this:
-
- #define EV_COMMON \
- SV *self; /* contains this struct */ \
- SV *cb_sv, *fh /* note no trailing ";" */
-
EV_PROTOTYPES
If defined to be "0", then "ev.h" will not define any function
@@ -177,6 +164,24 @@ PREPROCESSOR SYMBOLS
event loop pointer argument. Instead, all functions act on the
single default loop.
+ EV_PERIODICS
+
+ If undefined or defined to be "1", then periodic timers are
+ supported, otherwise not. This saves a few kb of code.
+
+ EV_COMMON
+
+ By default, all watchers have a "void *data" member. By redefining
+ this macro to a something else you can include more and other types
+ of members. You have to define it each time you include one of the
+ files, though, and it must be identical each time.
+
+ For example, the perl EV module uses this:
+
+ #define EV_COMMON \
+ SV *self; /* contains this struct */ \
+ SV *cb_sv, *fh /* note no trailing ";" */
+
EV_CB_DECLARE(type)
EV_CB_INVOKE(watcher,revents)
ev_set_cb(ev,cb)
diff --git a/ev++.C b/ev++.C
index f1f6ce0..d053c89 100644
--- a/ev++.C
+++ b/ev++.C
@@ -4,7 +4,9 @@ namespace ev {
extern "C" {
void cb_io (struct ev_io *w, int revents) { (*static_cast<io *>(w))(revents); }
void cb_timer (struct ev_timer *w, int revents) { (*static_cast<timer *>(w))(revents); }
+ #if EV_PERIODICS
void cb_periodic (struct ev_periodic *w, int revents) { (*static_cast<periodic *>(w))(revents); }
+ #endif
void cb_idle (struct ev_idle *w, int revents) { (*static_cast<idle *>(w))(revents); }
void cb_prepare (struct ev_prepare *w, int revents) { (*static_cast<prepare *>(w))(revents); }
void cb_check (struct ev_check *w, int revents) { (*static_cast<check *>(w))(revents); }
diff --git a/ev++.h b/ev++.h
index aa46fb4..500d596 100644
--- a/ev++.h
+++ b/ev++.h
@@ -129,6 +129,11 @@ namespace ev {
return call (this, events); \
} \
\
+ ~cppstem () \
+ { \
+ stop (); \
+ } \
+ \
private: \
\
cppstem (const cppstem &o) \
@@ -183,6 +188,7 @@ namespace ev {
}
};
+ #if EV_PERIODICS
EV_DECLARE_WATCHER (periodic, periodic)
void set (ev_tstamp at, ev_tstamp interval = 0.)
{
@@ -203,6 +209,7 @@ namespace ev {
ev_periodic_again (EV_A_ static_cast<ev_periodic *>(this));
}
};
+ #endif
EV_DECLARE_WATCHER (idle, idle)
};
diff --git a/ev.c b/ev.c
index 6affeea..266cbf8 100644
--- a/ev.c
+++ b/ev.c
@@ -806,7 +806,9 @@ loop_destroy (EV_P)
/* have to use the microsoft-never-gets-it-right macro */
array_free_microshit (fdchange);
array_free_microshit (timer);
+#if EV_PERIODICS
array_free_microshit (periodic);
+#endif
array_free_microshit (idle);
array_free_microshit (prepare);
array_free_microshit (check);
@@ -1003,6 +1005,7 @@ timers_reify (EV_P)
}
}
+#if EV_PERIODICS
static void
periodics_reify (EV_P)
{
@@ -1053,6 +1056,7 @@ periodics_reschedule (EV_P)
for (i = periodiccnt >> 1; i--; )
downheap ((WT *)periodics, periodiccnt, i);
}
+#endif
inline int
time_update_monotonic (EV_P)
@@ -1096,7 +1100,9 @@ time_update (EV_P)
now_floor = mn_now;
}
+# if EV_PERIODICS
periodics_reschedule (EV_A);
+# endif
/* no timer adjustment, as the monotonic clock doesn't jump */
/* timers_reschedule (EV_A_ rtmn_diff - odiff) */
}
@@ -1108,7 +1114,9 @@ time_update (EV_P)
if (expect_false (mn_now > ev_rt_now || mn_now < ev_rt_now - MAX_BLOCKTIME - MIN_TIMEJUMP))
{
+#if EV_PERIODICS
periodics_reschedule (EV_A);
+#endif
/* adjust timers. this is easy, as the offset is the same for all */
for (i = 0; i < timercnt; ++i)
@@ -1181,11 +1189,13 @@ ev_loop (EV_P_ int flags)
if (block > to) block = to;
}
+#if EV_PERIODICS
if (periodiccnt)
{
ev_tstamp to = ((WT)periodics [0])->at - ev_rt_now + method_fudge;
if (block > to) block = to;
}
+#endif
if (block < 0.) block = 0.;
}
@@ -1197,7 +1207,9 @@ ev_loop (EV_P_ int flags)
/* queue pending timers and reschedule them */
timers_reify (EV_A); /* relative timers called last */
+#if EV_PERIODICS
periodics_reify (EV_A); /* absolute timers called first */
+#endif
/* queue idle watchers unless io or timers are pending */
if (idlecnt && !any_pending (EV_A))
@@ -1358,6 +1370,7 @@ ev_timer_again (EV_P_ struct ev_timer *w)
ev_timer_start (EV_A_ w);
}
+#if EV_PERIODICS
void
ev_periodic_start (EV_P_ struct ev_periodic *w)
{
@@ -1406,6 +1419,7 @@ ev_periodic_again (EV_P_ struct ev_periodic *w)
ev_periodic_stop (EV_A_ w);
ev_periodic_start (EV_A_ w);
}
+#endif
void
ev_idle_start (EV_P_ struct ev_idle *w)
diff --git a/ev.h b/ev.h
index 369e45c..fec2ca4 100644
--- a/ev.h
+++ b/ev.h
@@ -48,6 +48,10 @@ typedef double ev_tstamp;
# define EV_MULTIPLICITY 1
#endif
+#ifndef EV_PERIODICS
+# define EV_PERIODICS 1
+#endif
+
/* support multiple event loops? */
#if EV_MULTIPLICITY
struct ev_loop;
@@ -370,9 +374,11 @@ void ev_timer_stop (EV_P_ struct ev_timer *w);
/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
void ev_timer_again (EV_P_ struct ev_timer *w);
+#if EV_PERIODICS
void ev_periodic_start (EV_P_ struct ev_periodic *w);
void ev_periodic_stop (EV_P_ struct ev_periodic *w);
void ev_periodic_again (EV_P_ struct ev_periodic *w);
+#endif
void ev_idle_start (EV_P_ struct ev_idle *w);
void ev_idle_stop (EV_P_ struct ev_idle *w);
diff --git a/ev_vars.h b/ev_vars.h
index 7e70143..77fa3d0 100644
--- a/ev_vars.h
+++ b/ev_vars.h
@@ -59,9 +59,11 @@ VARx(struct ev_timer **, timers)
VARx(int, timermax)
VARx(int, timercnt)
+#if EV_PERIODICS || EV_GENWRAP
VARx(struct ev_periodic **, periodics)
VARx(int, periodicmax)
VARx(int, periodiccnt)
+#endif
VARx(struct ev_idle **, idles)
VARx(int, idlemax)
diff --git a/ev_wrap.h b/ev_wrap.h
index d7d08ee..0777c7d 100644
--- a/ev_wrap.h
+++ b/ev_wrap.h
@@ -1,7 +1,6 @@
/* DO NOT EDIT, automaticlaly generated by update_ev_wrap */
#define now_floor ((loop)->now_floor)
#define mn_now ((loop)->mn_now)
-#define ev_rt_now ((loop)->ev_rt_now)
#define rtmn_diff ((loop)->rtmn_diff)
#define method ((loop)->method)
#define method_fudge ((loop)->method_fudge)