system_async_task.h
Go to the documentation of this file.
1 /*
2 ** Copyright 2014-2016 The Earlham Institute
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 
27 #ifndef SHARED_SRC_UTIL_INCLUDE_PROCESS_H_
28 #define SHARED_SRC_UTIL_INCLUDE_PROCESS_H_
29 
30 
32 #include "typedefs.h"
33 #include "operation.h"
34 #include "service_job.h"
35 #include "jobs_manager.h"
36 #include "async_task.h"
37 #include "memory_allocations.h"
38 
39 
44 typedef struct SystemAsyncTask
45 {
48 
54 
62 
65 
73 
74 
75 
76 
77 #ifdef __cplusplus
78 extern "C"
79 {
80 #endif
81 
82 
101 GRASSROOTS_TASK_API SystemAsyncTask *AllocateSystemAsyncTask (ServiceJob *job_p, const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, const char *command_s, void (*on_success_callback_fn) (ServiceJob *job_p));
102 
103 
114 GRASSROOTS_TASK_API bool SetSystemAsyncTaskCommand (SystemAsyncTask *task_p, const char *command_s);
115 
116 
123 GRASSROOTS_TASK_API void FreeSystemAsyncTask (SystemAsyncTask *task_p);
124 
125 
134 GRASSROOTS_TASK_API bool RunSystemAsyncTask (SystemAsyncTask *task_p);
135 
136 
147 GRASSROOTS_TASK_LOCAL void RunSystemAsyncTaskSuccess (SystemAsyncTask *task_p, ServiceJob *job_p);
148 
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 
155 #endif /* SHARED_SRC_UTIL_INCLUDE_PROCESS_H_ */
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:36
void FreeSystemAsyncTask(SystemAsyncTask *task_p)
Free a SystemAsyncTask.
char * std_command_line_s
The command line that this SystemAsyncTask will run.
Definition: system_async_task.h:64
SystemAsyncTask * AllocateSystemAsyncTask(ServiceJob *job_p, const char *name_s, struct AsyncTasksManager *manager_p, bool add_flag, const char *command_s, void(*on_success_callback_fn)(ServiceJob *job_p))
Allocate a SystemAsyncTask.
bool RunSystemAsyncTask(SystemAsyncTask *task_p)
Run a SystemAsyncTask.
void(* std_on_success_callback_fn)(ServiceJob *job_p)
The callback function that this SystemAsyncTask will call if it runs successfully.
Definition: system_async_task.h:71
bool SetSystemAsyncTaskCommand(SystemAsyncTask *task_p, const char *command_s)
Set the command line for a SystemAsyncTask to run.
AsyncTask * std_async_task_p
The underlying AsyncTask.
Definition: system_async_task.h:47
A datatype for storing AsyncTasks in a collection.
Definition: async_tasks_manager.h:24
MEM_FLAG std_async_task_mem
The MEM_FLAG determining whether the AsyncTask pointed to by std_async_task_p will be deleted when th...
Definition: system_async_task.h:53
A datatype to use to run tasks asynchronously.
Definition: async_task.h:24
A datatype to represent a running task.
Definition: service_job.h:72
ServiceJob * std_service_job_p
The ServiceJob that will run this SystemAsyncTask.
Definition: system_async_task.h:61
A datatype to allow the running of command-line applications in a separate task.
Definition: system_async_task.h:44