예제 #1
0
파일: cr.c 프로젝트: jimjag/libdill
int dill_ctx_cr_init(struct dill_ctx_cr *ctx) {
    /* This function is definitely called from the main coroutine, given that
       it's called only once and you can't even create a different coroutine
       without calling it. */
    ctx->r = &ctx->main;
    dill_qlist_init(&ctx->ready);
    dill_rbtree_init(&ctx->timers);
    /* We can't use now() here as the context is still being intialized. */
    ctx->last_poll = dill_mnow();
    /* Initialize the main coroutine. */
    memset(&ctx->main, 0, sizeof(ctx->main));
    ctx->main.ready.next = NULL;
    dill_slist_init(&ctx->main.clauses);
#if defined DILL_CENSUS
    dill_slist_init(&ctx->census);
#endif
    return 0;
}
예제 #2
0
파일: stack.c 프로젝트: paulofaria/libdill
int dill_ctx_stack_init(struct dill_ctx_stack *ctx) {
    ctx->count = 0;
    dill_qlist_init(&ctx->cache);
    return 0;
}