summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-12-08 03:53:36 +0000
committerroot <root>2007-12-08 03:53:36 +0000
commit7c2c0ecea2a4196af25910beaaf0faa4468e8e52 (patch)
tree61aeb9cd89513979ea8477ca4281b464f5622d33
parent40cacc255e3a1a5563eb1599fbea5f5d38ceb8eb (diff)
*** empty log message ***
-rw-r--r--ev.c42
-rw-r--r--ev.h1
-rw-r--r--ev.pod8
3 files changed, 37 insertions, 14 deletions
diff --git a/ev.c b/ev.c
index 48ff575..2001247 100644
--- a/ev.c
+++ b/ev.c
@@ -1525,7 +1525,7 @@ wlist_del (WL *head, WL elem)
}
void inline_speed
-ev_clear_pending (EV_P_ W w)
+clear_pending (EV_P_ W w)
{
if (w->pending)
{
@@ -1534,6 +1534,24 @@ ev_clear_pending (EV_P_ W w)
}
}
+void
+ev_clear_pending (EV_P_ void *w, int invoke)
+{
+ W w_ = (W)w;
+ int pending = w_->pending;
+
+ if (pending)
+ {
+ ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1;
+
+ w_->pending = 0;
+ p->w = 0;
+
+ if (invoke)
+ EV_CB_INVOKE (w_, p->events);
+ }
+}
+
void inline_size
pri_adjust (EV_P_ W w)
{
@@ -1580,7 +1598,7 @@ ev_io_start (EV_P_ ev_io *w)
void
ev_io_stop (EV_P_ ev_io *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -1613,7 +1631,7 @@ ev_timer_start (EV_P_ ev_timer *w)
void
ev_timer_stop (EV_P_ ev_timer *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -1681,7 +1699,7 @@ ev_periodic_start (EV_P_ ev_periodic *w)
void
ev_periodic_stop (EV_P_ ev_periodic *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -1745,7 +1763,7 @@ ev_signal_start (EV_P_ ev_signal *w)
void
ev_signal_stop (EV_P_ ev_signal *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -1772,7 +1790,7 @@ ev_child_start (EV_P_ ev_child *w)
void
ev_child_stop (EV_P_ ev_child *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2018,7 +2036,7 @@ ev_stat_start (EV_P_ ev_stat *w)
void
ev_stat_stop (EV_P_ ev_stat *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2054,7 +2072,7 @@ ev_idle_start (EV_P_ ev_idle *w)
void
ev_idle_stop (EV_P_ ev_idle *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2084,7 +2102,7 @@ ev_prepare_start (EV_P_ ev_prepare *w)
void
ev_prepare_stop (EV_P_ ev_prepare *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2111,7 +2129,7 @@ ev_check_start (EV_P_ ev_check *w)
void
ev_check_stop (EV_P_ ev_check *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2163,7 +2181,7 @@ ev_embed_start (EV_P_ ev_embed *w)
void
ev_embed_stop (EV_P_ ev_embed *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
@@ -2188,7 +2206,7 @@ ev_fork_start (EV_P_ ev_fork *w)
void
ev_fork_stop (EV_P_ ev_fork *w)
{
- ev_clear_pending (EV_A_ (W)w);
+ clear_pending (EV_A_ (W)w);
if (expect_false (!ev_is_active (w)))
return;
diff --git a/ev.h b/ev.h
index a0381c7..97c2f90 100644
--- a/ev.h
+++ b/ev.h
@@ -475,6 +475,7 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
void ev_feed_event (EV_P_ void *w, int revents);
void ev_feed_fd_event (EV_P_ int fd, int revents);
void ev_feed_signal_event (EV_P_ int signum);
+void ev_clear_pending (EV_P_ void *w, int invoke);
void ev_io_start (EV_P_ ev_io *w);
void ev_io_stop (EV_P_ ev_io *w);
diff --git a/ev.pod b/ev.pod
index d40456b..a578fd8 100644
--- a/ev.pod
+++ b/ev.pod
@@ -738,8 +738,9 @@ it.
Returns a true value iff the watcher is pending, (i.e. it has outstanding
events but its callback has not yet been invoked). As long as a watcher
is pending (but not active) you must not call an init function on it (but
-C<ev_TYPE_set> is safe) and you must make sure the watcher is available to
-libev (e.g. you cnanot C<free ()> it).
+C<ev_TYPE_set> is safe), you must not change its priority, and you must
+make sure the watcher is available to libev (e.g. you cannot C<free ()>
+it).
=item callback ev_cb (ev_TYPE *watcher)
@@ -768,6 +769,9 @@ watchers on the same event and make sure one is called first.
If you need to suppress invocation when higher priority events are pending
you need to look at C<ev_idle> watchers, which provide this functionality.
+You I<must not> change the priority of a watcher as long as it is active or
+pending.
+
The default priority used by watchers when no priority has been set is
always C<0>, which is supposed to not be too high and not be too low :).