AsyncTasksManager Struct Reference

A datatype for storing AsyncTasks in a collection. More...

#include <async_tasks_manager.h>

Collaboration diagram for AsyncTasksManager:
[legend]

Public Member Functions

AsyncTasksManagerAllocateAsyncTasksManager (const char *const name_s, bool(*cleanup_fn)(void *data_p), void *cleanup_data_p)
 Allocate an AsyncTasksManager with the given name. More...
 
void FreeAsyncTasksManager (AsyncTasksManager *manager_p)
 Free an AsyncTasksManager. More...
 
bool AddAsyncTaskToAsyncTasksManager (AsyncTasksManager *manager_p, AsyncTask *task_p, MEM_FLAG mem)
 Add an AsyncTask to a AsyncTasksManager. More...
 
SystemAsyncTaskAllocateSystemAsyncTaskFromAsyncTasksManager (AsyncTasksManager *manager_p, ServiceJob *std_service_job_p, char *std_command_line_s, void(*on_success_callback_fn)(ServiceJob *job_p))
 Allocate a SystemAsyncTask and add it a given AsyncTasksManager. More...
 
void PrepareAsyncTasksManager (AsyncTasksManager *manager_p, const int32 initial_counter_value)
 Perform the required functionality prior to running an AsyncTasksManager's AsyncTasks. More...
 
bool StartAsyncTaskManagerWorkers (AsyncTasksManager *manager_p)
 Start all AsyncTasks within an AsyncTasksManager. More...
 
bool RunAsyncTasksManagerTasks (AsyncTasksManager *manager_p)
 Run all AsyncTasks within an AsyncTasksManager. More...
 
bool IsAsyncTaskManagerRunning (const AsyncTasksManager *manager_p)
 Check whether an AsyncTasksManager has any AsyncTasks currently running,. More...
 
void IncrementAsyncTaskManagerCount (AsyncTasksManager *manager_p)
 Notify the AsyncTasksManager that one of its AsyncTasks has finished. More...
 

Data Fields

LinkedListatm_tasks_p
 LinkedList of AsyncTaskNodes for storing the AsyncTasks. More...
 
SyncDataatm_sync_p
 The SyncData used by the AsyncTasksManager to coordinate access across the differing threads. More...
 
struct CountAsyncTaskatm_monitor_p
 The CountAsyncTask that keeps the count of how many of the AsyncTasksManager's AsyncTasks have been completed. More...
 
struct AsyncTasksManagerEventConsumeratm_consumer_p
 The EventConsumer to call when all of this AsyncTasksManager's AsyncTasks have been completed. More...
 
bool(* atm_cleanup_fn )(void *data_p)
 This is the callback function that be called when this AsyncTaskManager's tasks have finished and any required deallocation routine is needed. More...
 
void * atm_cleanup_data_p
 The data to be passed to atm_cleanup_fn when this AsyncTaskManager's tasks have finished and any required deallocation routine is needed. More...
 
bool atm_in_use_flag
 This shows whether the AsyncTasksManager has any AsyncTasks currently running. More...
 

Detailed Description

A datatype for storing AsyncTasks in a collection.

Member Function Documentation

◆ AllocateAsyncTasksManager()

AsyncTasksManager * AllocateAsyncTasksManager ( const char *const  name_s,
bool(*)(void *data_p)  cleanup_fn,
void *  cleanup_data_p 
)

Allocate an AsyncTasksManager with the given name.

Parameters
name_sThe name to give to the AsyncTasksManager. This value will be deep-copied.
cleanup_fnThe callback function that the AsyncTasksManager will call when all of its AsyncTasks have finished. This is optional and can be NULL if not needed.
cleanup_data_pThe data to pass to the cleanup function when all of its AsyncTasks have finished. This is optional and can be NULL if not needed.
Returns
The new AsyncTasksManager or NULL upon error.

◆ FreeAsyncTasksManager()

void FreeAsyncTasksManager ( AsyncTasksManager manager_p)

Free an AsyncTasksManager.

Parameters
manager_pThe AsyncTasksManager to free.

◆ AddAsyncTaskToAsyncTasksManager()

bool AddAsyncTaskToAsyncTasksManager ( AsyncTasksManager manager_p,
AsyncTask task_p,
MEM_FLAG  mem 
)

Add an AsyncTask to a AsyncTasksManager.

Parameters
manager_pThe AsyncTasksManager that the given AsyncTask will be added to.
task_pThe AsyncTask to add.
memThe MEM_FLAG determining the ownership of the AsyncTask and if it will be freed when the AsyncTasksManager is freed.
Returns
true if the AsynTask was added successfully, false otherwise.

◆ AllocateSystemAsyncTaskFromAsyncTasksManager()

SystemAsyncTask * AllocateSystemAsyncTaskFromAsyncTasksManager ( AsyncTasksManager manager_p,
ServiceJob std_service_job_p,
char *  std_command_line_s,
void(*)(ServiceJob *job_p)  on_success_callback_fn 
)

Allocate a SystemAsyncTask and add it a given AsyncTasksManager.

Parameters
manager_pThe AsyncTasksManager to add the new SystemAsyncTask to
std_service_job_pThe ServiceJob that will run this SystemAsyncTask.
std_command_line_sThe command line that this SystemAsyncTask will run. The SystemAsyncTask will make a deep copy of this value.
on_success_callback_fnIf the SystemAsyncTask runs successfully, this function will be called with the SystemAsyncTask's ServiceJob as its parameter.
Returns
The newly-allocated SystemAsyncTask or NULL upon error.
See also
AllocateSystemAsyncTask()

◆ PrepareAsyncTasksManager()

void PrepareAsyncTasksManager ( AsyncTasksManager manager_p,
const int32  initial_counter_value 
)

Perform the required functionality prior to running an AsyncTasksManager's AsyncTasks.

Although you can call this, the wrapper function RunAsyncTasksManagerTasks() calls this then runs all of the AsyncTasks so may well be more useful.

Parameters
manager_pThe AsyncTasksManager which will be prepared prior to running its tasks.
initial_counter_valueThe value to be added to the size of the list of AsyncTasks that this AsyncTasksManager has. This is if you have custom behaviour in the Service. See PreRunJobs() in the Blast or Polymarker Service for examples of this.

◆ StartAsyncTaskManagerWorkers()

bool StartAsyncTaskManagerWorkers ( AsyncTasksManager manager_p)

Start all AsyncTasks within an AsyncTasksManager.

Parameters
manager_pThe AsyncTasksManager whose AsyncTasks will be ran.
Returns
true if all of the AsyncTasks were started successfully, false otherwise.

◆ RunAsyncTasksManagerTasks()

bool RunAsyncTasksManagerTasks ( AsyncTasksManager manager_p)

Run all AsyncTasks within an AsyncTasksManager.

This is simply a wrapper that calls PrepareAsyncTasksManager() followed by StartAsyncTaskManagerWorkers().

Parameters
manager_pThe AsyncTasksManager whose AsyncTasks will be ran.
Returns
true if all of the AsyncTasks were started successfully, false otherwise.

◆ IsAsyncTaskManagerRunning()

bool IsAsyncTaskManagerRunning ( const AsyncTasksManager manager_p)

Check whether an AsyncTasksManager has any AsyncTasks currently running,.

Parameters
manager_pThe AsyncTasksManager to check.
Returns
true if any AsyncTasks are currently running, false otherwise.

◆ IncrementAsyncTaskManagerCount()

void IncrementAsyncTaskManagerCount ( AsyncTasksManager manager_p)

Notify the AsyncTasksManager that one of its AsyncTasks has finished.

Parameters
manager_pThe AsyncTasksManager to amend.

Field Documentation

◆ atm_tasks_p

LinkedList* atm_tasks_p

LinkedList of AsyncTaskNodes for storing the AsyncTasks.

◆ atm_sync_p

SyncData* atm_sync_p

The SyncData used by the AsyncTasksManager to coordinate access across the differing threads.

◆ atm_monitor_p

struct CountAsyncTask* atm_monitor_p

The CountAsyncTask that keeps the count of how many of the AsyncTasksManager's AsyncTasks have been completed.

◆ atm_consumer_p

struct AsyncTasksManagerEventConsumer* atm_consumer_p

The EventConsumer to call when all of this AsyncTasksManager's AsyncTasks have been completed.

◆ atm_cleanup_fn

bool(* atm_cleanup_fn) (void *data_p)

This is the callback function that be called when this AsyncTaskManager's tasks have finished and any required deallocation routine is needed.

Parameters
data_pThe data to pass to the cleanup function. This will be atm_cleanup_data_p
Returns
true if the atm_cleanup_fn ran successfully, false otherwise.

◆ atm_cleanup_data_p

void* atm_cleanup_data_p

The data to be passed to atm_cleanup_fn when this AsyncTaskManager's tasks have finished and any required deallocation routine is needed.

◆ atm_in_use_flag

bool atm_in_use_flag

This shows whether the AsyncTasksManager has any AsyncTasks currently running.


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