/* event_get -- Return the next event associated with the specified handler. The event is removed from the queue if <remove> is non zero. */ at * event_get(void *handler, int remove) { at *pp = head; if (CONSP(pp)) { while (CONSP(pp->Cdr)) { at *p = pp->Cdr; void *hndl = ev_hndl(p->Car); if (hndl == handler) { at *event = p->Car->Cdr->Cdr; ev_parsedesc(p->Car->Cdr->Car); LOCK(event); if (remove) ev_remove(pp, p); return event; } if (hndl == 0) { ev_remove(pp, p); continue; } pp = p; } if (pp->Cdr) { at *p = pp->Cdr; pp->Cdr = NIL; UNLOCK(p); } } return NIL; }
/* event_get -- * Return the next event associated with the specified handler. * The event is removed from the queue if <remove> is true. */ at *event_get(void *handler, bool remove) { at *pp = head; if (CONSP(pp)) { while (CONSP(Cdr(pp))) { at *p = Cdr(pp); void *hndl = ev_hndl(Car(p)); if (hndl == handler) { at *event = Cdr(Cdar(p)); ev_parsedesc(Car(Cdar(p))); if (remove) ev_remove(pp, p); return event; } if (!hndl) { ev_remove(pp, p); continue; } pp = p; } if (Cdr(pp)) Cdr(pp) = NIL; } return NIL; }
static void ev_notify(at *handler, void *_) { at *pp = head; if (CONSP(pp)) { at *p = Cdr(pp); while (CONSP(p)) { void *hndl = ev_hndl(Car(p)); if (hndl==0 || hndl==(gptr)handler) ev_remove(pp, p); else pp = p; p = Cdr(pp); } } }
static void *ev_peek(void) { at *pp = head; if (CONSP(pp)) { while (CONSP(Cdr(pp))) { at *p = Cdr(pp); void *hndl = ev_hndl(Car(p)); if (hndl) return hndl; ev_remove(pp, p); } if (Cdr(pp)) Cdr(pp) = NIL; } return NULL; }
static void ev_finalize(at *handler, void *arg) { at *pp = head; if (CONSP(pp)) { at *p = pp->Cdr; while (CONSP(p)) { void *hndl = ev_hndl(p->Car); if ( hndl == 0 || hndl == (gptr)handler ) ev_remove(pp, p); else pp = p; p = pp->Cdr; } } }
static void * ev_peek(void) { at *pp = head; void *hndl; if (CONSP(pp)) { while (CONSP(pp->Cdr)) { at *p = pp->Cdr; if ((hndl = ev_hndl(p->Car))) return hndl; ev_remove(pp, p); } if (pp->Cdr) { at *p = pp->Cdr; pp->Cdr = NIL; UNLOCK(p); } } return 0; }