static void dill_bundle_close(struct dill_hvfs *vfs) { struct dill_bundle *self = (struct dill_bundle*)vfs; struct dill_list *it = &self->crs; for(it = self->crs.next; it != &self->crs; it = dill_list_next(it)) { struct dill_cr *cr = dill_cont(it, struct dill_cr, bundle); dill_cr_close(&cr->vfs); } if(!self->mem) free(self); }
void dill_timer_add(struct dill_timer *timer, int64_t deadline) { dill_assert(deadline >= 0); timer->expiry = deadline; /* Move the timer into the right place in the ordered list of existing timers. TODO: This is an O(n) operation! */ struct dill_list_item *it = dill_list_begin(&dill_timers); while(it) { struct dill_timer *tm = dill_cont(it, struct dill_timer, item); /* If multiple timers expire at the same momemt they will be fired in the order they were created in (> rather than >=). */ if(tm->expiry > timer->expiry) break; it = dill_list_next(it); } dill_list_insert(&dill_timers, &timer->item, it); }