Lines Matching refs:base
210 event_base_free(struct event_base *base) in event_base_free() argument
214 if (base == NULL && current_base) in event_base_free()
215 base = current_base; in event_base_free()
216 if (base == current_base) in event_base_free()
219 assert(base); in event_base_free()
220 assert(TAILQ_EMPTY(&base->eventqueue)); in event_base_free()
221 for (i=0; i < base->nactivequeues; ++i) in event_base_free()
222 assert(TAILQ_EMPTY(base->activequeues[i])); in event_base_free()
224 assert(RB_EMPTY(&base->timetree)); in event_base_free()
226 for (i = 0; i < base->nactivequeues; ++i) in event_base_free()
227 free(base->activequeues[i]); in event_base_free()
228 free(base->activequeues); in event_base_free()
230 if (base->evsel->dealloc != NULL) in event_base_free()
231 base->evsel->dealloc(base->evbase); in event_base_free()
233 free(base); in event_base_free()
243 event_base_priority_init(struct event_base *base, int npriorities) in event_base_priority_init() argument
247 if (base->event_count_active) in event_base_priority_init()
250 if (base->nactivequeues && npriorities != base->nactivequeues) { in event_base_priority_init()
251 for (i = 0; i < base->nactivequeues; ++i) { in event_base_priority_init()
252 free(base->activequeues[i]); in event_base_priority_init()
254 free(base->activequeues); in event_base_priority_init()
258 base->nactivequeues = npriorities; in event_base_priority_init()
259 base->activequeues = (struct event_list **)calloc(base->nactivequeues, in event_base_priority_init()
261 if (base->activequeues == NULL) in event_base_priority_init()
264 for (i = 0; i < base->nactivequeues; ++i) { in event_base_priority_init()
265 base->activequeues[i] = malloc(sizeof(struct event_list)); in event_base_priority_init()
266 if (base->activequeues[i] == NULL) in event_base_priority_init()
268 TAILQ_INIT(base->activequeues[i]); in event_base_priority_init()
275 event_haveevents(struct event_base *base) in event_haveevents() argument
277 return (base->event_count > 0); in event_haveevents()
287 event_process_active(struct event_base *base) in event_process_active() argument
294 if (!base->event_count_active) in event_process_active()
297 for (i = 0; i < base->nactivequeues; ++i) { in event_process_active()
298 if (TAILQ_FIRST(base->activequeues[i]) != NULL) { in event_process_active()
299 activeq = base->activequeues[i]; in event_process_active()
307 event_queue_remove(base, ev, EVLIST_ACTIVE); in event_process_active()
341 struct event_base *base = arg; in event_loopexit_cb() local
342 base->event_gotterm = 1; in event_loopexit_cb()
370 event_base_loop(struct event_base *base, int flags) in event_base_loop() argument
372 const struct eventop *evsel = base->evsel; in event_base_loop()
373 void *evbase = base->evbase; in event_base_loop()
380 if (evsel->recalc(base, evbase, 0) == -1) in event_base_loop()
384 if (base->event_gotterm) { in event_base_loop()
385 base->event_gotterm = 0; in event_base_loop()
403 if (timercmp(&tv, &base->event_tv, <)) { in event_base_loop()
407 timersub(&base->event_tv, &tv, &off); in event_base_loop()
408 timeout_correct(base, &off); in event_base_loop()
410 base->event_tv = tv; in event_base_loop()
412 if (!base->event_count_active && !(flags & EVLOOP_NONBLOCK)) in event_base_loop()
413 timeout_next(base, &tv); in event_base_loop()
418 if (!event_haveevents(base)) { in event_base_loop()
423 res = evsel->dispatch(base, evbase, &tv); in event_base_loop()
428 timeout_process(base); in event_base_loop()
430 if (base->event_count_active) { in event_base_loop()
431 event_process_active(base); in event_base_loop()
432 if (!base->event_count_active && (flags & EVLOOP_ONCE)) in event_base_loop()
528 event_base_set(struct event_base *base, struct event *ev) in event_base_set() argument
534 ev->ev_base = base; in event_base_set()
535 ev->ev_pri = base->nactivequeues/2; in event_base_set()
594 struct event_base *base = ev->ev_base; in event_add() local
595 const struct eventop *evsel = base->evsel; in event_add()
596 void *evbase = base->evbase; in event_add()
612 event_queue_remove(base, ev, EVLIST_TIMEOUT); in event_add()
627 event_queue_remove(base, ev, EVLIST_ACTIVE); in event_add()
637 event_queue_insert(base, ev, EVLIST_TIMEOUT); in event_add()
642 event_queue_insert(base, ev, EVLIST_INSERTED); in event_add()
647 event_queue_insert(base, ev, EVLIST_SIGNAL); in event_add()
658 struct event_base *base; in event_del() local
669 base = ev->ev_base; in event_del()
670 evsel = base->evsel; in event_del()
671 evbase = base->evbase; in event_del()
682 event_queue_remove(base, ev, EVLIST_TIMEOUT); in event_del()
685 event_queue_remove(base, ev, EVLIST_ACTIVE); in event_del()
688 event_queue_remove(base, ev, EVLIST_INSERTED); in event_del()
691 event_queue_remove(base, ev, EVLIST_SIGNAL); in event_del()
714 timeout_next(struct event_base *base, struct timeval *tv) in timeout_next() argument
721 if ((ev = RB_MIN(event_tree, &base->timetree)) == NULL) { in timeout_next()
744 timeout_correct(struct event_base *base, struct timeval *off) in timeout_correct() argument
752 RB_FOREACH(ev, event_tree, &base->timetree) in timeout_correct()
757 timeout_process(struct event_base *base) in timeout_process() argument
764 for (ev = RB_MIN(event_tree, &base->timetree); ev; ev = next) { in timeout_process()
767 next = RB_NEXT(event_tree, &base->timetree, ev); in timeout_process()
769 event_queue_remove(base, ev, EVLIST_TIMEOUT); in timeout_process()
781 event_queue_remove(struct event_base *base, struct event *ev, int queue) in event_queue_remove() argument
793 base->event_count--; in event_queue_remove()
799 base->event_count_active--; in event_queue_remove()
800 TAILQ_REMOVE(base->activequeues[ev->ev_pri], in event_queue_remove()
807 RB_REMOVE(event_tree, &base->timetree, ev); in event_queue_remove()
810 TAILQ_REMOVE(&base->eventqueue, ev, ev_next); in event_queue_remove()
818 event_queue_insert(struct event_base *base, struct event *ev, int queue) in event_queue_insert() argument
835 base->event_count++; in event_queue_insert()
841 base->event_count_active++; in event_queue_insert()
842 TAILQ_INSERT_TAIL(base->activequeues[ev->ev_pri], in event_queue_insert()
849 struct event *tmp = RB_INSERT(event_tree, &base->timetree, ev); in event_queue_insert()
854 TAILQ_INSERT_TAIL(&base->eventqueue, ev, ev_next); in event_queue_insert()