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 for storing AsyncTasks in a collection. More...
#include <async_tasks_manager.h>
Public Member Functions | |
AsyncTasksManager * | AllocateAsyncTasksManager (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... | |
SystemAsyncTask * | AllocateSystemAsyncTaskFromAsyncTasksManager (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 | |
LinkedList * | atm_tasks_p |
LinkedList of AsyncTaskNodes for storing the AsyncTasks. More... | |
SyncData * | atm_sync_p |
The SyncData used by the AsyncTasksManager to coordinate access across the differing threads. More... | |
struct CountAsyncTask * | atm_monitor_p |
The CountAsyncTask that keeps the count of how many of the AsyncTasksManager's AsyncTasks have been completed. More... | |
struct AsyncTasksManagerEventConsumer * | atm_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... | |
A datatype for storing AsyncTasks in a collection.
AsyncTasksManager * AllocateAsyncTasksManager | ( | const char *const | name_s, |
bool(*)(void *data_p) | cleanup_fn, | ||
void * | cleanup_data_p | ||
) |
Allocate an AsyncTasksManager with the given name.
name_s | The name to give to the AsyncTasksManager. This value will be deep-copied. |
cleanup_fn | The 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_p | The data to pass to the cleanup function when all of its AsyncTasks have finished. This is optional and can be NULL if not needed. |
NULL
upon error. void FreeAsyncTasksManager | ( | AsyncTasksManager * | manager_p | ) |
Free an AsyncTasksManager.
manager_p | The AsyncTasksManager to free. |
bool AddAsyncTaskToAsyncTasksManager | ( | AsyncTasksManager * | manager_p, |
AsyncTask * | task_p, | ||
MEM_FLAG | mem | ||
) |
Add an AsyncTask to a AsyncTasksManager.
manager_p | The AsyncTasksManager that the given AsyncTask will be added to. |
task_p | The AsyncTask to add. |
mem | The MEM_FLAG determining the ownership of the AsyncTask and if it will be freed when the AsyncTasksManager is freed. |
true
if the AsynTask was added successfully, false
otherwise. 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.
manager_p | The AsyncTasksManager to add the new SystemAsyncTask to |
std_service_job_p | The ServiceJob that will run this SystemAsyncTask. |
std_command_line_s | The command line that this SystemAsyncTask will run. The SystemAsyncTask will make a deep copy of this value. |
on_success_callback_fn | If the SystemAsyncTask runs successfully, this function will be called with the SystemAsyncTask's ServiceJob as its parameter. |
NULL
upon error. 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.
manager_p | The AsyncTasksManager which will be prepared prior to running its tasks. |
initial_counter_value | The 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. |
bool StartAsyncTaskManagerWorkers | ( | AsyncTasksManager * | manager_p | ) |
Start all AsyncTasks within an AsyncTasksManager.
manager_p | The AsyncTasksManager whose AsyncTasks will be ran. |
true
if all of the AsyncTasks were started successfully, false
otherwise. bool RunAsyncTasksManagerTasks | ( | AsyncTasksManager * | manager_p | ) |
Run all AsyncTasks within an AsyncTasksManager.
This is simply a wrapper that calls PrepareAsyncTasksManager() followed by StartAsyncTaskManagerWorkers().
manager_p | The AsyncTasksManager whose AsyncTasks will be ran. |
true
if all of the AsyncTasks were started successfully, false
otherwise. bool IsAsyncTaskManagerRunning | ( | const AsyncTasksManager * | manager_p | ) |
Check whether an AsyncTasksManager has any AsyncTasks currently running,.
manager_p | The AsyncTasksManager to check. |
true
if any AsyncTasks are currently running, false
otherwise. void IncrementAsyncTaskManagerCount | ( | AsyncTasksManager * | manager_p | ) |
Notify the AsyncTasksManager that one of its AsyncTasks has finished.
manager_p | The AsyncTasksManager to amend. |
LinkedList* atm_tasks_p |
LinkedList of AsyncTaskNodes for storing the AsyncTasks.
SyncData* atm_sync_p |
The SyncData used by the AsyncTasksManager to coordinate access across the differing threads.
struct CountAsyncTask* atm_monitor_p |
The CountAsyncTask that keeps the count of how many of the AsyncTasksManager's AsyncTasks have been completed.
struct AsyncTasksManagerEventConsumer* atm_consumer_p |
The EventConsumer to call when all of this AsyncTasksManager's AsyncTasks have been completed.
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.
data_p | The data to pass to the cleanup function. This will be atm_cleanup_data_p |
true
if the atm_cleanup_fn ran successfully, false
otherwise. 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.
bool atm_in_use_flag |
This shows whether the AsyncTasksManager has any AsyncTasks currently running.