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.
async_tasks_manager.h
Go to the documentation of this file.
1 /*
2  * async_task_manager.h
3  *
4  * Created on: 12 May 2017
5  * Author: billy
6  */
7 
8 #ifndef CORE_SERVER_TASK_INCLUDE_ASYNC_TASKS_MANAGER_H_
9 #define CORE_SERVER_TASK_INCLUDE_ASYNC_TASKS_MANAGER_H_
10 
11 
12 #include "async_task.h"
13 #include "count_async_task.h"
14 #include "system_async_task.h"
15 
16 
17 /* forward declaration */
19 
20 
24 typedef struct AsyncTasksManager
25 {
28 
34 
35 
42 
48 
49 
57  bool (*atm_cleanup_fn) (void *data_p);
58 
64 
70 
71 
77 {
80 
84 
85 
86 
87 
88 
89 
90 
91 #ifdef __cplusplus
92 extern "C"
93 {
94 #endif
95 
96 
110 GRASSROOTS_TASK_API AsyncTasksManager *AllocateAsyncTasksManager (const char * const name_s, bool (*cleanup_fn) (void *data_p), void *cleanup_data_p);
111 
112 
120 
121 
133 
134 
149 GRASSROOTS_TASK_API SystemAsyncTask *AllocateSystemAsyncTaskFromAsyncTasksManager (AsyncTasksManager *manager_p, ServiceJob *std_service_job_p, char *std_command_line_s, void (*on_success_callback_fn) (ServiceJob *job_p));
150 
160 
161 
169 
170 
185 GRASSROOTS_TASK_API void PrepareAsyncTasksManager (AsyncTasksManager *manager_p, const int32 initial_counter_value);
186 
187 
197 
198 
211 
212 
222 
223 
224 
232 
233 
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #endif /* CORE_SERVER_TASK_INCLUDE_ASYNC_TASKS_MANAGER_H_ */
AsyncTasksManager::PrepareAsyncTasksManager
void PrepareAsyncTasksManager(AsyncTasksManager *manager_p, const int32 initial_counter_value)
Perform the required functionality prior to running an AsyncTasksManager's AsyncTasks.
AsyncTasksManager::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 requ...
Definition: async_tasks_manager.h:63
AsyncTasksManager::atm_in_use_flag
bool atm_in_use_flag
This shows whether the AsyncTasksManager has any AsyncTasks currently running.
Definition: async_tasks_manager.h:68
AsyncTasksManagerEventConsumer::FreeAsyncTasksManagerEventConsumer
void FreeAsyncTasksManagerEventConsumer(AsyncTasksManagerEventConsumer *consumer_p)
Free an AsyncTasksManagerEventConsumer.
MEM_FLAG
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
ServiceJob
A datatype to represent a running task.
Definition: service_job.h:72
AsyncTasksManager::AddAsyncTaskToAsyncTasksManager
bool AddAsyncTaskToAsyncTasksManager(AsyncTasksManager *manager_p, AsyncTask *task_p, MEM_FLAG mem)
Add an AsyncTask to a AsyncTasksManager.
AsyncTasksManager::atm_sync_p
SyncData * atm_sync_p
The SyncData used by the AsyncTasksManager to coordinate access across the differing threads.
Definition: async_tasks_manager.h:33
AsyncTasksManager::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...
Definition: async_tasks_manager.h:57
AsyncTasksManager::atm_monitor_p
struct CountAsyncTask * atm_monitor_p
The CountAsyncTask that keeps the count of how many of the AsyncTasksManager's AsyncTasks have been c...
Definition: async_tasks_manager.h:41
AsyncTasksManager::atm_consumer_p
struct AsyncTasksManagerEventConsumer * atm_consumer_p
The EventConsumer to call when all of this AsyncTasksManager's AsyncTasks have been completed.
Definition: async_tasks_manager.h:47
count_async_task.h
system_async_task.h
process.h
AsyncTasksManager::AllocateAsyncTasksManager
AsyncTasksManager * AllocateAsyncTasksManager(const char *const name_s, bool(*cleanup_fn)(void *data_p), void *cleanup_data_p)
Allocate an AsyncTasksManager with the given name.
AsyncTasksManagerEventConsumer::atmec_tasks_manager_p
AsyncTasksManager * atmec_tasks_manager_p
The AsyncTasksManager that owns this AsyncTasksManagerEventConsumer.
Definition: async_tasks_manager.h:82
AsyncTasksManagerEventConsumer
A datatype that has an EventConsumer and a pointer to the AsyncTasksManager that owns it.
Definition: async_tasks_manager.h:76
CountAsyncTask
A datatype for an AsyncTask that has a counter that sends a signal when that counter reaches a given ...
Definition: count_async_task.h:23
AsyncTasksManager::IncrementAsyncTaskManagerCount
void IncrementAsyncTaskManagerCount(AsyncTasksManager *manager_p)
Notify the AsyncTasksManager that one of its AsyncTasks has finished.
AsyncTask
A datatype to use to run tasks asynchronously.
Definition: async_task.h:25
AsyncTasksManagerEventConsumer::AllocateAsyncTasksManagerEventConsumer
AsyncTasksManagerEventConsumer * AllocateAsyncTasksManagerEventConsumer(void(*consumer_fn)(EventConsumer *consumer_p, struct AsyncTask *task_p), AsyncTasksManager *manager_p)
Create a new AsyncTasksManagerEventConsumer and store it in the given AsyncTasksManager.
AsyncTasksManager::StartAsyncTaskManagerWorkers
bool StartAsyncTaskManagerWorkers(AsyncTasksManager *manager_p)
Start all AsyncTasks within an AsyncTasksManager.
GRASSROOTS_TASK_API
#define GRASSROOTS_TASK_API
Definition: grassroots_task_library.h:46
LinkedList
A doubly-linked list that can be traversed in either direction.
Definition: linked_list.h:56
AsyncTasksManager::RunAsyncTasksManagerTasks
bool RunAsyncTasksManagerTasks(AsyncTasksManager *manager_p)
Run all AsyncTasks within an AsyncTasksManager.
SyncData
A datatype that allows data to be shared between tasks (e.g.
Definition: linux_sync_data.h:30
AsyncTasksManager
A datatype for storing AsyncTasks in a collection.
Definition: async_tasks_manager.h:24
AsyncTasksManager::IsAsyncTaskManagerRunning
bool IsAsyncTaskManagerRunning(const AsyncTasksManager *manager_p)
Check whether an AsyncTasksManager has any AsyncTasks currently running,.
async_task.h
EventConsumer
An EvenetConsumer is a datatype to allow an object to be notified when an AsyncTask has completed run...
Definition: event_consumer.h:44
SystemAsyncTask
A datatype to allow the running of command-line applications in a separate task.
Definition: system_async_task.h:44
AsyncTasksManager::AllocateSystemAsyncTaskFromAsyncTasksManager
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.
AsyncTasksManagerEventConsumer::atmec_base_consumer
EventConsumer atmec_base_consumer
The EventConsumer.
Definition: async_tasks_manager.h:79
AsyncTasksManager::atm_tasks_p
LinkedList * atm_tasks_p
LinkedList of AsyncTaskNodes for storing the AsyncTasks.
Definition: async_tasks_manager.h:27
AsyncTasksManager::FreeAsyncTasksManager
void FreeAsyncTasksManager(AsyncTasksManager *manager_p)
Free an AsyncTasksManager.