count_async_task.h
1 /*
2  * count_async_task_resource.h
3  *
4  * Created on: 9 May 2017
5  * Author: billy
6  */
7 
8 #ifndef CORE_SERVER_TASK_INCLUDE_COUNT_ASYNC_TASK_H_
9 #define CORE_SERVER_TASK_INCLUDE_COUNT_ASYNC_TASK_H_
10 
11 #include "async_task.h"
12 
13 
23 typedef struct CountAsyncTask
24 {
27 
30 
35  int32 cat_limit;
37 
38 
39 
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 
45 
57 GRASSROOTS_TASK_API CountAsyncTask *AllocateCountAsyncTask (const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, int32 limit);
58 
59 
73 GRASSROOTS_TASK_API bool InitCountAsyncTask (CountAsyncTask *count_task_p, const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, int32 limit);
74 
82 GRASSROOTS_TASK_API AsyncTask *GetAsyncTaskFromCountAsyncTask (CountAsyncTask *count_task_p);
83 
84 
91 GRASSROOTS_TASK_API void FreeCountAsyncTask (CountAsyncTask *count_task_p);
92 
93 
100 GRASSROOTS_TASK_API void ClearCountAsyncTask (CountAsyncTask *count_task_p);
101 
102 
114 GRASSROOTS_TASK_API bool IncrementCountAsyncTask (CountAsyncTask *count_task_p);
115 
116 
126 GRASSROOTS_TASK_API bool ContinueCountAsyncTask (const CountAsyncTask *count_task_p);
127 
128 
136 GRASSROOTS_TASK_API void SetCountAsyncTaskLimit (CountAsyncTask *task_p, int32 limit);
137 
138 
139 
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 
146 #endif /* CORE_SERVER_TASK_INCLUDE_COUNT_ASYNC_TASK_H_ */
void SetCountAsyncTaskLimit(CountAsyncTask *task_p, int32 limit)
Set the limit for a given CountAsyncTask.
bool ContinueCountAsyncTask(const CountAsyncTask *count_task_p)
The default callback function to check whether a CountAsyncTask could continue running.
AsyncTask * cat_task_p
The underlying AsyncTask.
Definition: count_async_task.h:26
bool InitCountAsyncTask(CountAsyncTask *count_task_p, const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, int32 limit)
Initialise a CountAsyncTask.
int32 cat_limit
The value at which this CountAsyncTask will send the message saying that it has completed.
Definition: count_async_task.h:35
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
bool IncrementCountAsyncTask(CountAsyncTask *count_task_p)
Increment the counter for a given CountAsyncTask.
A datatype for storing AsyncTasks in a collection.
Definition: async_tasks_manager.h:24
CountAsyncTask * AllocateCountAsyncTask(const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, int32 limit)
Allocate a CountAsyncTask.
void FreeCountAsyncTask(CountAsyncTask *count_task_p)
Free a CountAsyncTask.
A datatype to use to run tasks asynchronously.
Definition: async_task.h:24
int32 cat_current_value
The current value of the counter for this CountAsyncTask.
Definition: count_async_task.h:29
void ClearCountAsyncTask(CountAsyncTask *count_task_p)
Remove and free the underlying AsyncTask from a given CountAsyncTask.
AsyncTask * GetAsyncTaskFromCountAsyncTask(CountAsyncTask *count_task_p)
Get the underlying AsyncTask for a given CountAsyncTask.