Example #1
0
hlt_execution_context* __hlt_execution_context_new_ref(hlt_vthread_id vid, int8_t run_module_init)
{
    hlt_execution_context* ctx = (hlt_execution_context*)hlt_malloc(sizeof(hlt_execution_context) +
                                                                    __hlt_globals()->globals_size);

    ctx->vid = vid;
    ctx->nullbuffer = __hlt_memory_nullbuffer_new(); // init first
    ctx->excpt = 0;
    ctx->fiber = 0;
    ctx->fiber_pool = __hlt_fiber_pool_new();
    ctx->worker = 0;
    ctx->tcontext = 0;
    ctx->tcontext_type = 0;
    ctx->pstate = 0;
    ctx->blockable = 0;
    ctx->tmgr = hlt_timer_mgr_new(&ctx->excpt, ctx);
    GC_CCTOR(ctx->tmgr, hlt_timer_mgr, ctx);

    __hlt_globals_init(ctx);

    if ( run_module_init )
        __hlt_modules_init(ctx);

    if ( ctx->excpt )
        hlt_exception_print_uncaught_abort(ctx->excpt, ctx);

    return ctx;
}
Example #2
0
void __hlt_fiber_init()
{
    if ( ! hlt_is_multi_threaded() ) {
        __hlt_globals()->synced_fiber_pool = 0;
        return;
    }

    if ( pthread_mutex_init(&__hlt_globals()->synced_fiber_pool_lock, 0) != 0 )
        fatal_error("cannot init mutex");

    __hlt_globals()->synced_fiber_pool = __hlt_fiber_pool_new();
}