summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-11-08 21:08:56 +0000
committerroot <root>2007-11-08 21:08:56 +0000
commit48151275f9dd2099bb2e98f47a341678182d9230 (patch)
treeb28beeed4f402e75438fc206fee927f28f0753e2
parent286fec65d89d8f47f6171ca9978294ce4b4e6ba8 (diff)
add ev_feed_event
-rw-r--r--ev.c34
-rw-r--r--ev.h6
-rw-r--r--event.h1
3 files changed, 25 insertions, 16 deletions
diff --git a/ev.c b/ev.c
index b852e45..8a32229 100644
--- a/ev.c
+++ b/ev.c
@@ -318,19 +318,21 @@ anfds_init (ANFD *base, int count)
}
}
-static void
-event (EV_P_ W w, int events)
+void
+ev_feed_event (EV_P_ void *w, int revents)
{
- if (w->pending)
+ W w_ = (W)w;
+
+ if (w_->pending)
{
- pendings [ABSPRI (w)][w->pending - 1].events |= events;
+ pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
return;
}
- w->pending = ++pendingcnt [ABSPRI (w)];
- array_needsize (ANPENDING, pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void));
- pendings [ABSPRI (w)][w->pending - 1].w = w;
- pendings [ABSPRI (w)][w->pending - 1].events = events;
+ w_->pending = ++pendingcnt [ABSPRI (w_)];
+ array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void));
+ pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
+ pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
}
static void
@@ -339,7 +341,7 @@ queue_events (EV_P_ W *events, int eventcnt, int type)
int i;
for (i = 0; i < eventcnt; ++i)
- event (EV_A_ events [i], type);
+ ev_feed_event (EV_A_ events [i], type);
}
static void
@@ -353,7 +355,7 @@ fd_event (EV_P_ int fd, int events)
int ev = w->events & events;
if (ev)
- event (EV_A_ (W)w, ev);
+ ev_feed_event (EV_A_ (W)w, ev);
}
}
@@ -405,7 +407,7 @@ fd_kill (EV_P_ int fd)
while ((w = (struct ev_io *)anfds [fd].head))
{
ev_io_stop (EV_A_ w);
- event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
+ ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
}
}
@@ -571,7 +573,7 @@ sigcb (EV_P_ struct ev_io *iow, int revents)
signals [signum].gotsig = 0;
for (w = signals [signum].head; w; w = w->next)
- event (EV_A_ (W)w, EV_SIGNAL);
+ ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
}
}
@@ -615,7 +617,7 @@ child_reap (EV_P_ struct ev_signal *sw, int chain, int pid, int status)
ev_priority (w) = ev_priority (sw); /* need to do it *now* */
w->rpid = pid;
w->rstatus = status;
- event (EV_A_ (W)w, EV_CHILD);
+ ev_feed_event (EV_A_ (W)w, EV_CHILD);
}
}
@@ -627,7 +629,7 @@ childcb (EV_P_ struct ev_signal *sw, int revents)
if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
{
/* make sure we are called again until all childs have been reaped */
- event (EV_A_ (W)sw, EV_SIGNAL);
+ ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
child_reap (EV_A_ sw, pid, pid, status);
child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
@@ -948,7 +950,7 @@ timers_reify (EV_P)
else
ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
- event (EV_A_ (W)w, EV_TIMEOUT);
+ ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
}
}
@@ -978,7 +980,7 @@ periodics_reify (EV_P)
else
ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
- event (EV_A_ (W)w, EV_PERIODIC);
+ ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
}
}
diff --git a/ev.h b/ev.h
index 61c88a5..c49a4dd 100644
--- a/ev.h
+++ b/ev.h
@@ -197,6 +197,7 @@ struct ev_child
int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
};
+/* the presence of this union forces similar struct layout */
union ev_any_watcher
{
struct ev_watcher w;
@@ -326,6 +327,11 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
/* stopping (enabling, adding) a watcher does nothing if it is already running */
/* stopping (disabling, deleting) a watcher does nothing unless its already running */
#if EV_PROTOTYPES
+
+/* feeds an event into a watcher as if the event actually occured */
+/* accepts any ev_watcher type */
+void ev_feed_event (EV_P_ void *w, int revents);
+
void ev_io_start (EV_P_ struct ev_io *w);
void ev_io_stop (EV_P_ struct ev_io *w);
diff --git a/event.h b/event.h
index 5226924..76a521a 100644
--- a/event.h
+++ b/event.h
@@ -104,6 +104,7 @@ int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg,
int event_add (struct event *ev, struct timeval *tv);
int event_del (struct event *ev);
+void event_active(struct event *ev, int res, short ncalls); /* ncalls is being ignored */
int event_pending (struct event *ev, short, struct timeval *tv);