|
Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
|
A datatype to use to run tasks asynchronously. More...
#include <async_task.h>
Public Member Functions | |
| AsyncTask * | AllocateAsyncTask (const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag) |
| Create an AsyncTask. More... | |
| void | FreeAsyncTask (AsyncTask *task_p) |
| Free an AsyncTask. More... | |
| bool | InitialiseAsyncTask (AsyncTask *task_p, const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag) |
| Initialise an AsyncTask. More... | |
| void | ClearAsyncTask (AsyncTask *task_p) |
| Clear an AsyncTask. More... | |
| void | CloseAsyncTask (AsyncTask *task_p) |
| Stop a the given AsyncTask if it is currently running. More... | |
| bool | SetAsyncTaskSyncData (AsyncTask *task_p, SyncData *sync_data_p, MEM_FLAG mem) |
| Set the SyncData for an AsyncTask. More... | |
| void | SetAsyncTaskRunData (AsyncTask *task_p, void *(*run_fn)(void *data_p), void *data_p) |
| Set the callback function that an AsyncTask will call when it is ran. More... | |
| bool | IsAsyncTaskRunning (const AsyncTask *task_p) |
| Check whether an AsyncTask is currently running. More... | |
| bool | RunAsyncTask (AsyncTask *task_p) |
| Run an AsyncTask. More... | |
| AsyncTaskNode * | AllocateAsyncTaskNode (AsyncTask *task_p, MEM_FLAG mem) |
| Create an AsyncTaskNode. More... | |
| void | FreeAsyncTaskNode (ListItem *node_p) |
| Free an AsyncTaskNode. More... | |
| void | SetAsyncTaskConsumer (AsyncTask *task_p, EventConsumer *consumer_p, MEM_FLAG mem) |
| Set the EventConsumer for a given AsyncTask. More... | |
| void | RunEventConsumerFromAsyncTask (AsyncTask *task_p) |
| Run the EventConsumer for the given AsyncTask. More... | |
Data Fields | |
| char * | at_name_s |
| The name of the AsyncTask. More... | |
| struct SyncData * | at_sync_data_p |
| The SyncData used to coordinate data access between the AsyncTask and other processes. More... | |
| MEM_FLAG | at_sync_data_mem |
| The memory flag indicating the ownership of the SyncData. More... | |
| void *(* | at_run_fn )(void *data_p) |
| The callback function that will be run as a separate task by this AsyncTask. More... | |
| void * | at_data_p |
| Any custom data that will be passed to at_fun_fn. More... | |
| EventConsumer * | at_consumer_p |
| An EventConsumer to notify when the AsyncTask has finished running. More... | |
| MEM_FLAG | at_consumer_mem |
| The memory flag indicating the ownership of the EventConsumer. More... | |
| struct AsyncTasksManager * | at_manager_p |
| The AsyncTasksManager that has this AsyncTask. More... | |
A datatype to use to run tasks asynchronously.
| AsyncTask * AllocateAsyncTask | ( | const char * | name_s, |
| struct AsyncTasksManager * | manager_p, | ||
| bool | add_flag | ||
| ) |
Create an AsyncTask.
| name_s | The optional name to give to the AsyncTask. This will be deep-copied by the AsyncTask so this value doesn't have to stay in scope. |
| manager_p | The AsyncTasksManager that will own this AsyncTask. |
| add_flag | If this is true then the newly-allocated AsyncTask will be added to the given AsyncTasksManager's list of AsyncTasks, false otherwise. |
NULL upon error. | void FreeAsyncTask | ( | AsyncTask * | task_p | ) |
| bool InitialiseAsyncTask | ( | AsyncTask * | task_p, |
| const char * | name_s, | ||
| struct AsyncTasksManager * | manager_p, | ||
| bool | add_flag | ||
| ) |
Initialise an AsyncTask.
| task_p | The AsyncTask to initialise. |
| name_s | The optional name to give to the AsyncTask. This will be deep-copied by the AsyncTask so this value doesn't have to stay in scope. |
| manager_p | The AsyncTasksManager that will own this AsyncTask. |
| add_flag | If this is true then the newly-allocated AsyncTask will be added to the given AsyncTasksManager's list of AsyncTasks, false otherwise. |
true if the AsyncTask was started successfully, false otherwise. | void ClearAsyncTask | ( | AsyncTask * | task_p | ) |
| void CloseAsyncTask | ( | AsyncTask * | task_p | ) |
| void SetAsyncTaskRunData | ( | AsyncTask * | task_p, |
| void *(*)(void *data_p) | run_fn, | ||
| void * | data_p | ||
| ) |
Set the callback function that an AsyncTask will call when it is ran.
| task_p | The AsyncTask to run. |
| run_fn | The function that the AsyncTask will run. It will be called with the task_data_p parameter. |
| data_p | The parameter to use when calling run_fn. |
true if the AsyncTask was started successfully, false otherwise. | bool IsAsyncTaskRunning | ( | const AsyncTask * | task_p | ) |
| bool RunAsyncTask | ( | AsyncTask * | task_p | ) |
| AsyncTaskNode * AllocateAsyncTaskNode | ( | AsyncTask * | task_p, |
| MEM_FLAG | mem | ||
| ) |
Create an AsyncTaskNode.
| task_p | The AsyncTask to store in the newly-created AsyncTaskNode. |
| mem | The MEM_FLAG specifying how the AsyncTask will be dealt with when the AsyncTaskNode is freed. |
NULL upon error. | void FreeAsyncTaskNode | ( | ListItem * | node_p | ) |
Free an AsyncTaskNode.
| node_p | The AsyncTaskNode to free. |
| void SetAsyncTaskConsumer | ( | AsyncTask * | task_p, |
| EventConsumer * | consumer_p, | ||
| MEM_FLAG | mem | ||
| ) |
Set the EventConsumer for a given AsyncTask.
| task_p | The AsyncTask to adjust. |
| consumer_p | The EventConsumer to add to the given AsyncTask. |
| mem | The MEM_FLAG specifying how the EvenetConsumer will be treated when the AsyncTask is freed. |
| void RunEventConsumerFromAsyncTask | ( | AsyncTask * | task_p | ) |
Run the EventConsumer for the given AsyncTask.
| task_p | The AsyncTask to run. |
| char* at_name_s |
The name of the AsyncTask.
| struct SyncData* at_sync_data_p |
| void*(* at_run_fn) (void *data_p) |
| void* at_data_p |
Any custom data that will be passed to at_fun_fn.
| EventConsumer* at_consumer_p |
An EventConsumer to notify when the AsyncTask has finished running.
| MEM_FLAG at_consumer_mem |
The memory flag indicating the ownership of the EventConsumer.
| struct AsyncTasksManager* at_manager_p |
The AsyncTasksManager that has this AsyncTask.