Robust Distributed System Nucleus (rDSN)  ver 1.0.0
Functions
Asynchronous Tasks and Timers

Overview

Functions

DSN_API dsn_task_t dsn_task_create (dsn_task_code_t code, dsn_task_handler_t cb, void *context, int hash DEFAULT(0), dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API dsn_task_t dsn_task_create_timer (dsn_task_code_t code, dsn_task_handler_t cb, void *context, int hash, int interval_milliseconds, dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API dsn_task_t dsn_task_create_ex (dsn_task_code_t code, dsn_task_handler_t cb, dsn_task_cancelled_handler_t on_cancel, void *context, int hash DEFAULT(0), dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API dsn_task_t dsn_task_create_timer_ex (dsn_task_code_t code, dsn_task_handler_t cb, dsn_task_cancelled_handler_t on_cancel, void *context, int hash, int interval_milliseconds, dsn_task_tracker_t tracker DEFAULT(nullptr))
 
DSN_API void dsn_task_call (dsn_task_t task, int delay_milliseconds DEFAULT(0))
 

Function Documentation

DSN_API dsn_task_t dsn_task_create ( dsn_task_code_t  code,
dsn_task_handler_t  cb,
void *  context,
int hash   DEFAULT0,
dsn_task_tracker_t tracker   DEFAULTnullptr 
)

create an asynchronous task.

Parameters
codethe task code, which defines which thread pool executes the task, see dsn_task_code_register for more details.
cbthe callback for executing the task.
contextthe context used by the callback.
DEFAULT(0)the hash value, which defines which thread in the target thread pool executes the task, when the pool is partitioned, see remarks for more.
DEFAULT(nullptr)the task tracker handle, see dsn_task_tracker_create for more.
Returns
task handle

code defines the thread pool which executes the callback, i.e., [task.code$] pool_code = THREAD_POOL_DEFAULT; hash defines the thread with index hash % worker_count in the threadpool to execute the callback, when [threadpool.pool_code%] partitioned = true.

DSN_API dsn_task_t dsn_task_create_timer ( dsn_task_code_t  code,
dsn_task_handler_t  cb,
void *  context,
int  hash,
int  interval_milliseconds,
dsn_task_tracker_t tracker   DEFAULTnullptr 
)

create a timer task

Parameters
codethe task code, which defines which thread pool executes the task, see dsn_task_code_register for more details.
cbthe callback for executing the task.
contextthe context used by the callback.
DEFAULT(0)the hash value, which defines which thread in the target thread pool executes the task, when the pool is partitioned, see remarks for more.
interval_millisecondstimer interval with which the timer executes periodically.
DEFAULT(nullptr)the task tracker handle, see dsn_task_tracker_create for more.
Returns
task handle

code defines the thread pool which executes the callback, i.e., [task.code$] pool_code = THREAD_POOL_DEFAULT; hash defines the thread with index hash % worker_count in the threadpool to execute the callback, when [threadpool.pool_code%] partitioned = true.

DSN_API void dsn_task_call ( dsn_task_t  task,
int delay_milliseconds   DEFAULT
)

start the task

Parameters
taskthe task handle
delay_millisecondsdelay time before its execution