Exemplo n.º 1
0
        task_ptr enqueue(
            dsn_task_code_t evt,
            servicelet *context,
            task_handler callback,
            int hash /*= 0*/,
            int delay_milliseconds /*= 0*/,
            int timer_interval_milliseconds /*= 0*/
            )
        {                
            dsn_task_t t;
            task_ptr tsk = new safe_task<task_handler>(callback, timer_interval_milliseconds != 0);
                
            tsk->add_ref(); // released in exec callback
            if (timer_interval_milliseconds != 0)
            { 
                t = dsn_task_create_timer(evt, safe_task<task_handler>::exec, tsk, hash, timer_interval_milliseconds);
            }   
            else
            {
                t = dsn_task_create(evt, safe_task<task_handler>::exec, tsk, hash);
            }

            tsk->set_task_info(t);

            dsn_task_call(t, context ? context->tracker() : nullptr, delay_milliseconds);
            return tsk;
        }
Exemplo n.º 2
0
DSN_PY_API dsn_task_t dsn_task_create_timer_helper(dsn_task_code_t code, uint64_t param, int hash, int interval_milliseconds, dsn_task_tracker_t tracker)
{
    return dsn_task_create_timer(code, timer_handler, (void*)(uintptr_t)param, hash, interval_milliseconds, nullptr); // set tracker null
}