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.
AsyncTask Struct Reference

A datatype to use to run tasks asynchronously. More...

#include <async_task.h>

Collaboration diagram for AsyncTask:
[legend]

Public Member Functions

AsyncTaskAllocateAsyncTask (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...
 
AsyncTaskNodeAllocateAsyncTaskNode (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 SyncDataat_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...
 
EventConsumerat_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 AsyncTasksManagerat_manager_p
 The AsyncTasksManager that has this AsyncTask. More...
 

Detailed Description

A datatype to use to run tasks asynchronously.

Member Function Documentation

◆ AllocateAsyncTask()

AsyncTask * AllocateAsyncTask ( const char *  name_s,
struct AsyncTasksManager manager_p,
bool  add_flag 
)

Create an AsyncTask.

Parameters
name_sThe 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_pThe AsyncTasksManager that will own this AsyncTask.
add_flagIf this is true then the newly-allocated AsyncTask will be added to the given AsyncTasksManager's list of AsyncTasks, false otherwise.
Returns
The new AsyncTask or NULL upon error.

◆ FreeAsyncTask()

void FreeAsyncTask ( AsyncTask task_p)

Free an AsyncTask.

If it is currently running, it will be stopped first by calling CloseAsyncTask ().

Parameters
task_pThe AsyncTask to free.

◆ InitialiseAsyncTask()

bool InitialiseAsyncTask ( AsyncTask task_p,
const char *  name_s,
struct AsyncTasksManager manager_p,
bool  add_flag 
)

Initialise an AsyncTask.

Parameters
task_pThe AsyncTask to initialise.
name_sThe 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_pThe AsyncTasksManager that will own this AsyncTask.
add_flagIf this is true then the newly-allocated AsyncTask will be added to the given AsyncTasksManager's list of AsyncTasks, false otherwise.
Returns
true if the AsyncTask was started successfully, false otherwise.

◆ ClearAsyncTask()

void ClearAsyncTask ( AsyncTask task_p)

Clear an AsyncTask.

If it is currently running, it will be stopped first by calling CloseAsyncTask ().

Parameters
task_pThe AsyncTask to clear.

◆ CloseAsyncTask()

void CloseAsyncTask ( AsyncTask task_p)

Stop a the given AsyncTask if it is currently running.

Parameters
task_pThe AsyncTask to stop.

◆ SetAsyncTaskSyncData()

bool SetAsyncTaskSyncData ( AsyncTask task_p,
SyncData sync_data_p,
MEM_FLAG  mem 
)

Set the SyncData for an AsyncTask.

Parameters
task_pThe AsyncTask to amend.
sync_data_pThe SyncData to set.
memThe MEM_FLAG specifying how the SyncData will be dealt with when the AsyncTask is freed.
Returns
true if the AsyncTask was altered successfully, false otherwise.

◆ SetAsyncTaskRunData()

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.

Parameters
task_pThe AsyncTask to run.
run_fnThe function that the AsyncTask will run. It will be called with the task_data_p parameter.
data_pThe parameter to use when calling run_fn.
Returns
true if the AsyncTask was started successfully, false otherwise.

◆ IsAsyncTaskRunning()

bool IsAsyncTaskRunning ( const AsyncTask task_p)

Check whether an AsyncTask is currently running.

Parameters
task_pThe AsyncTask to check.
Returns
true if the AsyncTask is running, false otherwise.

◆ RunAsyncTask()

bool RunAsyncTask ( AsyncTask task_p)

Run an AsyncTask.

Parameters
task_pThe AsyncTask to run.
Returns
true if the AsyncTask was started successfully, false otherwise.

◆ AllocateAsyncTaskNode()

AsyncTaskNode * AllocateAsyncTaskNode ( AsyncTask task_p,
MEM_FLAG  mem 
)

Create an AsyncTaskNode.

Parameters
task_pThe AsyncTask to store in the newly-created AsyncTaskNode.
memThe MEM_FLAG specifying how the AsyncTask will be dealt with when the AsyncTaskNode is freed.
Returns
The new AsyncTaskNode or NULL upon error.

◆ FreeAsyncTaskNode()

void FreeAsyncTaskNode ( ListItem node_p)

Free an AsyncTaskNode.

Parameters
node_pThe AsyncTaskNode to free.

◆ SetAsyncTaskConsumer()

void SetAsyncTaskConsumer ( AsyncTask task_p,
EventConsumer consumer_p,
MEM_FLAG  mem 
)

Set the EventConsumer for a given AsyncTask.

Parameters
task_pThe AsyncTask to adjust.
consumer_pThe EventConsumer to add to the given AsyncTask.
memThe MEM_FLAG specifying how the EvenetConsumer will be treated when the AsyncTask is freed.

◆ RunEventConsumerFromAsyncTask()

void RunEventConsumerFromAsyncTask ( AsyncTask task_p)

Run the EventConsumer for the given AsyncTask.

Parameters
task_pThe AsyncTask to run.

Field Documentation

◆ at_name_s

char* at_name_s

The name of the AsyncTask.

◆ at_sync_data_p

struct SyncData* at_sync_data_p

The SyncData used to coordinate data access between the AsyncTask and other processes.

◆ at_sync_data_mem

MEM_FLAG at_sync_data_mem

The memory flag indicating the ownership of the SyncData.

◆ at_run_fn

void*(* at_run_fn) (void *data_p)

The callback function that will be run as a separate task by this AsyncTask.

Parameters
data_pThe AsyncTask's custom data.

◆ at_data_p

void* at_data_p

Any custom data that will be passed to at_fun_fn.

◆ at_consumer_p

EventConsumer* at_consumer_p

An EventConsumer to notify when the AsyncTask has finished running.

◆ at_consumer_mem

MEM_FLAG at_consumer_mem

The memory flag indicating the ownership of the EventConsumer.

◆ at_manager_p

struct AsyncTasksManager* at_manager_p

The AsyncTasksManager that has this AsyncTask.


The documentation for this struct was generated from the following file: