DAOS API (v2.1 - dev)
|
#include <gurt/list.h>
#include <pthread.h>
#include <inttypes.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | tse_task |
struct | tse_sched_t |
Macros | |
#define | TSE_TASK_ARG_LEN (840 + sizeof(pthread_mutex_t)) |
#define | TSE_PRIV_SIZE (TSE_TASK_ARG_LEN + 136) |
#define | TSE_TASK_SIZE (TSE_PRIV_SIZE + 8) |
Typedefs | |
typedef struct tse_task | tse_task_t |
typedef int(* | tse_sched_comp_cb_t) (void *args, int rc) |
typedef int(* | tse_task_func_t) (tse_task_t *) |
typedef int(* | tse_task_cb_t) (tse_task_t *, void *arg) |
Task Execution Engine: Generic scheduler for creating tasks and dependencies between them.
Definition in file tse.h.
#define TSE_PRIV_SIZE (TSE_TASK_ARG_LEN + 136) |
#define TSE_TASK_ARG_LEN (840 + sizeof(pthread_mutex_t)) |
#define TSE_TASK_SIZE (TSE_PRIV_SIZE + 8) |
typedef int(* tse_sched_comp_cb_t) (void *args, int rc) |
typedef int(* tse_task_cb_t) (tse_task_t *, void *arg) |
typedef int(* tse_task_func_t) (tse_task_t *) |
typedef struct tse_task tse_task_t |
struct for a task object that is used for tracking an operation
void tse_disable_propagate | ( | tse_task_t * | task | ) |
Set the task don't propagate err-code from dependent tasks.
void tse_sched_addref | ( | tse_sched_t * | sched | ) |
Take reference of the scheduler.
[in] | sched | the scheduler pointer. |
bool tse_sched_check_complete | ( | tse_sched_t * | sched | ) |
Check completion on all tasks in the scheduler.
[in] | sched | Schedule to check. |
void tse_sched_complete | ( | tse_sched_t * | sched, |
int | ret, | ||
bool | cancel ) |
Wait for all tasks in the scheduler to complete and finalize it. If another thread is completing the scheduler, this returns immediately.
[in] | sched | scheduler to be completed. |
[in] | ret | result for scheduler completion. |
[in] | cancel | cancel all tasks in scheduler if true. |
void tse_sched_decref | ( | tse_sched_t * | sched | ) |
Release reference of the scheduler.
[in] | sched | the scheduler pointer. |
void tse_sched_fini | ( | tse_sched_t * | sched | ) |
Finish the scheduler.
[in] | sched | the scheduler to be finished. |
int tse_sched_init | ( | tse_sched_t * | sched, |
tse_sched_comp_cb_t | comp_cb, | ||
void * | udata ) |
Initialize the scheduler with an optional completion callback and pointer to user data. Caller is responsible to complete or cancel the scheduler.
[in] | sched | scheduler to be initialized. |
[in] | comp_cb | Optional callback to be called when scheduler is done. |
[in] | udata | Optional pointer to user data to associate with the scheduler. This is stored in ds_udata in the scheduler struct and passed in to comp_cb as the argument when the callback is invoked. |
void tse_sched_progress | ( | tse_sched_t * | sched | ) |
Make progress on scheduler. Runs tasks that are ready to be executed after the tasks they depend on were completed. Note that task completion using tse_task_complete() must be done by the engine user to push progress on the engine. In DAOS tse_task_complete is called by the completion CB of the RPC request that is sent to the server.
[in] | sched | Scheduler to make progress on. |
int tse_sched_register_comp_cb | ( | tse_sched_t * | sched, |
tse_sched_comp_cb_t | comp_cb, | ||
void * | arg ) |
register complete callback for scheduler.
[in] | sched | scheduler where to register the completion callback. |
[in] | comp_cb | completion callback to be registered. |
[in] | arg | argument of the completion callback. |
void * tse_task2arg | ( | tse_task_t * | task | ) |
Convert from task to arg
tse_sched_t * tse_task2sched | ( | tse_task_t * | task | ) |
Return scheduler task is associated with
void tse_task_addref | ( | tse_task_t * | task | ) |
Take reference on the task
void * tse_task_buf_embedded | ( | tse_task_t * | task, |
int | size ) |
Get embedded buffer of a task, user can use it to carry function parameters. Embedded buffer of task has size limit, this function will return NULL if buf_size is larger than the limit.
User should use private data by tse_task_set_priv() to pass large parameter.
[in] | task | task to get the buffer. |
[in] | size | task buffer size. |
void tse_task_complete | ( | tse_task_t * | task, |
int | ret ) |
Mark task as completed.
[in] | task | task to be completed. |
[in] | ret | ret result of the task. |
int tse_task_create | ( | tse_task_func_t | task_func, |
tse_sched_t * | sched, | ||
void * | priv, | ||
tse_task_t ** | taskp ) |
Initialize the tse_task.
The task will be added to the scheduler task list, and being scheduled later, if dependent task is provided, then the task will be added to the dep list of the dependent task, once the dependent task is done, then the task will be added to the scheduler list.
[in] | task_func | the function to be executed when the task is executed. |
[in] | sched | daos scheduler where the daos task will be attached to. |
[in] | priv | private data passed into the task, user can get it by calling tse_task_get_priv, or rewrite by calling tse_task_set_priv. |
[out] | taskp | pointer to tse_task to be allocated and initialized. The task is freed internally when complete is called. |
void tse_task_decref | ( | tse_task_t * | task | ) |
Drop reference on the task
int tse_task_depend_list | ( | tse_task_t * | task, |
d_list_t * | head ) |
task depends on all tasks attached on list head
void * tse_task_get_priv | ( | tse_task_t * | task | ) |
Return the private data of the task. Private data can be set while creating task, or by calling tse_task_set_priv.
void tse_task_list_abort | ( | d_list_t * | head, |
int | rc ) |
Abort all tasks attached on list head.
int tse_task_list_add | ( | tse_task_t * | task, |
d_list_t * | head ) |
Add a newly created task to a list. It returns error if the task is already running or completed.
void tse_task_list_del | ( | tse_task_t * | task | ) |
Remove the task from list head.
int tse_task_list_depend | ( | d_list_t * | head, |
tse_task_t * | task ) |
All tasks attached on head depend on list task.
tse_task_t * tse_task_list_first | ( | d_list_t * | head | ) |
The first task linked on list head, it returns NULL if the list is empty.
void tse_task_list_sched | ( | d_list_t * | head, |
bool | instant ) |
Schedule all tasks attached on list head.
int tse_task_list_traverse | ( | d_list_t * | head, |
tse_task_cb_t | cb, | ||
void * | arg ) |
Traverse all tasks on list head, invoke the cb with parameter of arg on each task. User is free to remove the task from the list head within the cb's executing.
int tse_task_list_traverse_adv | ( | d_list_t * | head, |
tse_task_cb_t | cb, | ||
void * | arg ) |
Advanced tse_task_list_traverse, the task's dtp_task_list or head list possibly be changed/zeroed after cb executed.
int tse_task_register_cbs | ( | tse_task_t * | task, |
tse_task_cb_t | prep_cb, | ||
void * | prep_data, | ||
size_t | prep_data_size, | ||
tse_task_cb_t | comp_cb, | ||
void * | comp_data, | ||
size_t | comp_data_size ) |
Register prepare and completion callbacks that will be executed right before the task is scheduled and after it completes respectively.
[in] | task | Task to add CBs on. |
[in] | prep_cb | Prepare callback. |
[in] | prep_data_size | Size of the user provided prep data to be copied internally. |
[in] | prep_data | User data passed to the prepare callback. |
[in] | comp_cb | Completion callback |
[in] | comp_data_size | Size of the user provided comp data to be copied internally. |
[in] | comp_data | User data passed to the completion callback. |
int tse_task_register_comp_cb | ( | tse_task_t * | task, |
tse_task_cb_t | comp_cb, | ||
void * | arg, | ||
size_t | arg_size ) |
register complete callback for the task.
[in] | task | task to be registered complete callback. |
[in] | comp_cb | complete callback. |
[in] | arg | callback argument. |
[in] | arg_size | size of the argument. |
int tse_task_register_deps | ( | tse_task_t * | task, |
int | num_deps, | ||
tse_task_t * | dep_tasks[] ) |
Register dependency tasks that will be required to be completed before the the task can be scheduled. The dependency tasks cannot be in progress.
[in] | task | Task to add dependencies for. |
[in] | num_deps | Number of tasks in the task array. |
[in] | dep_tasks | Task array for all the tasks that are required to complete before the task can scheduled. |
int tse_task_reinit | ( | tse_task_t * | task | ) |
Reinitialize a task and move it into the scheduler's initialize list. The task must have a body function to be reinserted into the scheduler. Once the task being reinitialized, it possible be executed by other thread when it progresses the scheduler. So all accesses to the task must happen before the reinit call, for example task dependency/callback registration or task argument accessing.
[in] | task | Task to reinitialize |
int tse_task_reinit_with_delay | ( | tse_task_t * | task, |
uint64_t | delay ) |
Same as tse_task_reinit, except that task will not be re-executed within delay microseconds.
[in] | task | Task to reinitialize |
[in] | delay | Scheduling delay in microseconds |
int tse_task_reset | ( | tse_task_t * | task, |
tse_task_func_t | task_func, | ||
void * | priv ) |
Reset a task with a new body function. The task must have already completed or not started yet, and must have a > 0 valid ref count (not freed). This allows a user to reuse a task with a different body function and not have to recreate a task for a different operation.
[in] | task | Task to reset |
[in] | task_func | the function to be executed when the task is executed. |
[in] | priv | private data passed into the task |
int tse_task_schedule | ( | tse_task_t * | task, |
bool | instant ) |
Add task to scheduler it was initialized with. If task body function should be called immediately as part of this function, instant should be set to true; otherwise if false task would be in the scheduler init list and progressed when the scheduler is progressed.
[in] | task | task to be scheduled. |
[in] | instant | flag to indicate whether task should be executed immediately. |
int tse_task_schedule_with_delay | ( | tse_task_t * | task, |
bool | instant, | ||
uint64_t | delay ) |
Same as tse_task_schedule, expect that task will not be executed within delay microseconds if instant is false.
[in] | task | task to be scheduled. |
[in] | instant | flag to indicate whether task should be executed immediately. |
[in] | delay | scheduling delay in microseconds. |
void * tse_task_set_priv | ( | tse_task_t * | task, |
void * | priv ) |
Set or change the private data of the task. The original private data will be returned.