Lely core libraries  2.3.4
stop.h
Go to the documentation of this file.
1 
24 #ifndef LELY_UTIL_STOP_H_
25 #define LELY_UTIL_STOP_H_
26 
27 #include <lely/util/sllist.h>
28 
34 typedef struct stop_token stop_token_t;
35 
40 typedef struct stop_source stop_source_t;
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
51 struct stop_func {
53  void (*func)(struct stop_func *func);
54  // The node of this callback in a queue.
55  struct slnode _node;
56 };
57 
59 #define STOP_FUNC_INIT(func) \
60  { \
61  (func), SLNODE_INIT \
62  }
63 
73 
82 void stop_token_release(stop_token_t *token);
83 
92 int stop_token_stop_requested(const stop_token_t *token);
93 
104 int stop_token_stop_possible(const stop_token_t *token);
105 
116 int stop_token_insert(stop_token_t *token, struct stop_func *func);
117 
128 void stop_token_remove(stop_token_t *token, struct stop_func *func);
129 
140 
150 
159 void stop_source_release(stop_source_t *source);
160 
174 
183 int stop_source_stop_requested(const stop_source_t *source);
184 
190 
191 #ifdef __cplusplus
192 }
193 #endif
194 
195 #endif // !LELY_UTIL_STOP_H_
This header file is part of the utilities library; it contains the singly-linked list declarations.
int stop_token_insert(stop_token_t *token, struct stop_func *func)
Registers a callback function with the specified stop token.
Definition: stop.c:163
void stop_token_release(stop_token_t *token)
Releases a reference to a stop token.
Definition: stop.c:121
int stop_source_request_stop(stop_source_t *source)
Issues a stop request to the stop-state associated with the specified stop source,...
Definition: stop.c:291
stop_token_t * stop_source_get_token(stop_source_t *source)
Returns (a reference to) a stop token associated with the specified stop source's stop-state.
Definition: stop.c:381
void stop_source_release(stop_source_t *source)
Releases a reference to a stop source.
Definition: stop.c:273
int stop_source_stop_requested(const stop_source_t *source)
Checks if the stop-state associated with the specified stop source has received a stop request.
Definition: stop.c:366
stop_source_t * stop_source_acquire(stop_source_t *source)
Acquires a reference to a stop source.
Definition: stop.c:254
void stop_token_remove(stop_token_t *token, struct stop_func *func)
Deregisters a callback function from the specified stop token.
Definition: stop.c:199
int stop_token_stop_possible(const stop_token_t *token)
Checks if the stop-state associated with the specified stop token has received a stop request,...
Definition: stop.c:149
int stop_token_stop_requested(const stop_token_t *token)
Checks if the stop-state associated with the specified stop token has received a stop request.
Definition: stop.c:143
stop_token_t * stop_token_acquire(stop_token_t *token)
Acquires a reference to a stop token.
Definition: stop.c:104
stop_source_t * stop_source_create(void)
Creates a stop source with a new stop-state.
Definition: stop.c:227
A node in a singly-linked list.
Definition: sllist.h:40
An object providing the means to register a callback function with an stop_token_t object.
Definition: stop.h:51
void(* func)(struct stop_func *func)
The function to be invoked when a stop request is issued.
Definition: stop.h:53
A stop source.
Definition: stop.c:71
A stop token.
Definition: stop.c:40