Example #1
0
File: debug.c Project: 8l/libmill
void mill_register_cr(struct mill_debug_cr *cr, const char *created) {
    mill_list_insert(&mill_all_crs, &cr->item, NULL);
    cr->id = mill_next_cr_id;
    ++mill_next_cr_id;
    cr->created = created;
    cr->current = NULL;
}
Example #2
0
/* Wait for events from a file descriptor, with an optional timeout. */
int mill_fdwait(int fd, int events, int64_t deadline, const char *current) {
    /* If required, start waiting for the timeout. */
    if(deadline >= 0) {
        mill_running->u_fdwait.expiry = deadline;
        /* Move the timer into the right place in the ordered list
           of existing timers. TODO: This is an O(n) operation! */
        struct mill_list_item *it = mill_list_begin(&mill_timers);
        while(it) {
            struct mill_fdwait *timer = mill_cont(it, struct mill_fdwait, item);
            /* If multiple timers expire at the same momemt they will be fired
               in the order they were created in (> rather than >=). */
            if(timer->expiry > mill_running->u_fdwait.expiry)
                break;
            it = mill_list_next(it);
        }
        mill_list_insert(&mill_timers, &mill_running->u_fdwait.item, it);
    }
Example #3
0
void mill_timer_add(struct mill_timer *timer, int64_t deadline,
                    mill_timer_callback callback) {
    mill_assert(deadline >= 0);
    timer->expiry = deadline;
    timer->callback = callback;
    /* Move the timer into the right place in the ordered list
     of existing timers. TODO: This is an O(n) operation! */
    struct mill_list_item *it = mill_list_begin(&mill_timers);
    while(it) {
        struct mill_timer *tm = mill_cont(it, struct mill_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 = mill_list_next(it);
    }
    mill_list_insert(&mill_timers, &timer->item, it);
}
Example #4
0
File: debug.c Project: 8l/libmill
void mill_register_chan(struct mill_debug_chan *ch, const char *created) {
    mill_list_insert(&mill_all_chans, &ch->item, NULL);
    ch->id = mill_next_chan_id;
    ++mill_next_chan_id;
    ch->created = created;
}