示例#1
0
文件: fiber.c 项目: Chunjie/hilti
int8_t hlt_fiber_start(hlt_fiber* fiber, hlt_execution_context* ctx)
{
    int init = (fiber->state == INIT);

    __hlt_context_set_fiber(fiber->context, fiber);

    if ( ! _setjmp(fiber->parent) ) {
        fiber->state = RUNNING;

        if ( init )
            setcontext(&fiber->uctx);
        else
            _longjmp(fiber->fiber, 1);

        abort();
    }

    switch ( fiber->state ) {
     case YIELDED:
        __hlt_memory_safepoint(fiber->context, "fiber_start/yield");
        return 0;

     case IDLE:
        __hlt_memory_safepoint(fiber->context, "fiber_start/done");
        __hlt_context_set_fiber(fiber->context, 0);
        hlt_fiber_delete(fiber, ctx);
        return 1;

     default:
        abort();
    }
}
示例#2
0
文件: context.c 项目: rsmmr/hilti
void hlt_execution_context_delete(hlt_execution_context* ctx)
{
    hlt_exception* excpt = 0;

    // Do this first, it may still need the context.
    hlt_timer_mgr_expire(ctx->tmgr, 0, &excpt, ctx);
    GC_DTOR(ctx->tmgr, hlt_timer_mgr, ctx);

    __hlt_globals_dtor(ctx);

    GC_DTOR(ctx->excpt, hlt_exception, ctx);

    if ( ctx->fiber )
        hlt_fiber_delete(ctx->fiber, ctx);

    if ( ctx->pstate )
        __hlt_profiler_state_delete(ctx->pstate);

    if ( ctx->tcontext ) {
        GC_DTOR_GENERIC(&ctx->tcontext, ctx->tcontext_type, ctx);
    }

    __hlt_fiber_pool_delete(ctx->fiber_pool);

    if ( ctx->nullbuffer )
        __hlt_memory_nullbuffer_delete(ctx->nullbuffer, ctx);

    hlt_free(ctx);
}
示例#3
0
文件: exceptions.c 项目: rsmmr/hilti
void hlt_exception_dtor(hlt_type_info* ti, hlt_exception* excpt, hlt_execution_context* ctx)
{
    if ( excpt->arg ) {
        GC_DTOR_GENERIC(excpt->arg, excpt->type->argtype, ctx);
        hlt_free(excpt->arg);
    }

    if ( excpt->fiber )
        hlt_fiber_delete(excpt->fiber, 0);
}