hi all.there are several questions about memcache source code when i study .the
event_base event_base has two member: eventqueue and activequeues.the event
struct has two member: ev_flags and ev_res.which queue one event is put into is
according to the values of ev_flags and ev_res.in event_add function,there are
the followint codes:
if (tv != NULL) { struct timeval now;
if (ev->ev_flags & EVLIST_TIMEOUT) event_queue_remove(base, ev,
EVLIST_TIMEOUT);
/* Check if it is active due to a timeout. Rescheduling * this timeout
before the callback can be executed * removes it from the active list. */ if
((ev->ev_flags & EVLIST_ACTIVE) && (ev->ev_res & EV_TIMEOUT)) { /* See
if we are just active executing this * event in a loop */ if
(ev->ev_ncalls && ev->ev_pncalls) { /* Abort loop */ *ev->ev_pncalls = 0;
} event_queue_remove(base, ev, EVLIST_ACTIVE); }
gettime(&now); timeradd(&now, tv, &ev->ev_timeout);
event_debug(( "event_add: timeout in %d seconds, call %p", tv->tv_sec,
ev->ev_callback));
event_queue_insert(base, ev, EVLIST_TIMEOUT); }
if ((ev->ev_events & (EV_READ|EV_WRITE)) && !(ev->ev_flags &
(EVLIST_INSERTED|EVLIST_ACTIVE))) { event_queue_insert(base, ev,
EVLIST_INSERTED);
above codes imply that the IO events are put into the event_base's
eventqueue.but event_process_active function only deals with the events those
are put into the activequeues.the ev_flags and ev_res both can be set the
following
value:EVLIST_TIMEOUT,EVLIST_INSERTED,EVLIST_SIGNAL,EVLIST_ACTIVE,EVLIST_INTERNAL
and EVLIST_INIT,the ev_res is defined as result passed to event callback.
my questions are what defference between the activequeues and eventqueue,what
defference between EVLIST_INSERTED and EVLIST_ACTIVE,what use of the ev_res.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/