/* Unblock a coroutine blocked in mill_choose_wait() function. It also cleans up the associated clause list. */ static void mill_choose_unblock(struct mill_clause *cl) { struct mill_slist_item *it; struct mill_clause *itcl; for(it = mill_slist_begin(&cl->cr->u_choose.clauses); it; it = mill_slist_next(it)) { itcl = mill_cont(it, struct mill_clause, chitem); if(!itcl->used) continue; mill_list_erase(&itcl->ep->clauses, &itcl->epitem); } mill_resume(cl->cr, cl->idx); }
int mill_timer_fire(void) { /* Avoid getting current time if there are no timers anyway. */ if(mill_list_empty(&mill_timers)) return 0; int64_t nw = now(); int fired = 0; while(!mill_list_empty(&mill_timers)) { struct mill_timer *tm = mill_cont( mill_list_begin(&mill_timers), struct mill_timer, item); if(tm->expiry > nw) break; mill_list_erase(&mill_timers, mill_list_begin(&mill_timers)); if(tm->callback) tm->callback(tm); fired = 1; } return fired; }
void mill_unregister_chan(struct mill_debug_chan *ch) { mill_list_erase(&mill_all_chans, &ch->item); }
void mill_unregister_cr(struct mill_debug_cr *cr) { mill_list_erase(&mill_all_crs, &cr->item); }
void mill_timer_rm(struct mill_timer *timer) { mill_list_erase(&mill_timers, &timer->item); }
void mill_timer_rm(struct mill_timer *timer) { mill_assert(timer->expiry >= 0); mill_list_erase(&mill_timers, &timer->item); timer->expiry = -1; }