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
34typedef struct stop_token stop_token_t;
35
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
51struct 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
83
93
104int stop_token_stop_possible(const stop_token_t *token);
105
116int stop_token_insert(stop_token_t *token, struct stop_func *func);
117
128void stop_token_remove(stop_token_t *token, struct stop_func *func);
129
140
150
160
174
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
stop_source_t * stop_source_acquire(stop_source_t *source)
Acquires a reference to a stop source.
Definition stop.c:254
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
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
stop_source_t * stop_source_create(void)
Creates a stop source with a new stop-state.
Definition stop.c:227
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
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