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.
event_consumer.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 CORE_SERVER_TASK_INCLUDE_EVENT_CONSUMER_H_
28 #define CORE_SERVER_TASK_INCLUDE_EVENT_CONSUMER_H_
29 
30 
32 #include "typedefs.h"
33 
34 
35 
36 /* forward declaration */
37 struct EventConsumer;
38 struct AsyncTask;
39 
44 typedef struct EventConsumer
45 {
52  void (*at_consumer_fn) (struct EventConsumer *consumer_p, struct AsyncTask *task_p);
54 
55 
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
61 
69 GRASSROOTS_TASK_API EventConsumer *AllocateEventConsumer (void (*consumer_fn) (EventConsumer *consumer_p, struct AsyncTask *task_p));
70 
71 
80 GRASSROOTS_TASK_API bool InitEventConsumer (EventConsumer *consumer_p, void (*consumer_fn) (EventConsumer *consumer_p, struct AsyncTask *task_p));
81 
82 
90 
91 
99 
100 
108 GRASSROOTS_TASK_API void RunEventConsumer (EventConsumer *consumer_p, struct AsyncTask *task_p);
109 
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 
116 #endif /* CORE_SERVER_TASK_INCLUDE_EVENT_CONSUMER_H_ */
EventConsumer::FreeEventConsumer
void FreeEventConsumer(EventConsumer *consumer_p)
Free an EventConsumer.
EventConsumer::RunEventConsumer
void RunEventConsumer(EventConsumer *consumer_p, struct AsyncTask *task_p)
Fire an EventConsumer's callback function to notify that the given AsyncTask has completed.
grassroots_task_library.h
AsyncTask
A datatype to use to run tasks asynchronously.
Definition: async_task.h:25
typedefs.h
EventConsumer::at_consumer_fn
void(* at_consumer_fn)(struct EventConsumer *consumer_p, struct AsyncTask *task_p)
The callback function to call when an AsyncTask has completed.
Definition: event_consumer.h:52
GRASSROOTS_TASK_API
#define GRASSROOTS_TASK_API
Definition: grassroots_task_library.h:46
EventConsumer
An EvenetConsumer is a datatype to allow an object to be notified when an AsyncTask has completed run...
Definition: event_consumer.h:44
EventConsumer::InitEventConsumer
bool InitEventConsumer(EventConsumer *consumer_p, void(*consumer_fn)(EventConsumer *consumer_p, struct AsyncTask *task_p))
Initialise an EventConsumer with a given callback function.
EventConsumer::ClearEventConsumer
void ClearEventConsumer(EventConsumer *consumer_p)
Clear an EventConsumer.
EventConsumer::AllocateEventConsumer
EventConsumer * AllocateEventConsumer(void(*consumer_fn)(EventConsumer *consumer_p, struct AsyncTask *task_p))
Allocate an EventConsumer to receive notification when an AsyncTask completes.