Loading...
Searching...
No Matches
event_loop.h
Go to the documentation of this file.
1
18#pragma once
19
20#include "base.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
104
107
118
123void furi_event_loop_free(FuriEventLoop* instance);
124
131void furi_event_loop_run(FuriEventLoop* instance);
132
137void furi_event_loop_stop(FuriEventLoop* instance);
138
139/*
140 * Tick related API
141 */
142
147typedef void (*FuriEventLoopTickCallback)(void* context);
148
162 FuriEventLoop* instance,
163 uint32_t interval,
165 void* context);
166
167/*
168 * Deferred function call API
169 */
170
177typedef void (*FuriEventLoopPendingCallback)(void* context);
178
189 FuriEventLoop* instance,
191 void* context);
192
193/*
194 * Event subscription/notification APIs
195 */
196
197typedef void FuriEventLoopObject;
198
204typedef void (*FuriEventLoopEventCallback)(FuriEventLoopObject* object, void* context);
205
207typedef struct FuriEventFlag FuriEventFlag;
208
221 FuriEventLoop* instance,
222 FuriEventFlag* event_flag,
223 FuriEventLoopEvent event,
225 void* context);
226
229
241 FuriEventLoop* instance,
242 FuriMessageQueue* message_queue,
243 FuriEventLoopEvent event,
245 void* context);
246
249
261 FuriEventLoop* instance,
262 FuriStreamBuffer* stream_buffer,
263 FuriEventLoopEvent event,
265 void* context);
266
269
281 FuriEventLoop* instance,
282 FuriSemaphore* semaphore,
283 FuriEventLoopEvent event,
285 void* context);
286
288typedef struct FuriMutex FuriMutex;
289
301 FuriEventLoop* instance,
302 FuriMutex* mutex,
303 FuriEventLoopEvent event,
305 void* context);
306
312void furi_event_loop_unsubscribe(FuriEventLoop* instance, FuriEventLoopObject* object);
313
320bool furi_event_loop_is_subscribed(FuriEventLoop* instance, FuriEventLoopObject* object);
321
325static inline void
326 furi_event_loop_maybe_unsubscribe(FuriEventLoop* instance, FuriEventLoopObject* object) {
327 if(furi_event_loop_is_subscribed(instance, object))
328 furi_event_loop_unsubscribe(instance, object);
329}
330
331#ifdef __cplusplus
332}
333#endif
void furi_event_loop_subscribe_stream_buffer(FuriEventLoop *instance, FuriStreamBuffer *stream_buffer, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to stream buffer events.
Definition event_loop.c:382
void furi_event_loop_subscribe_semaphore(FuriEventLoop *instance, FuriSemaphore *semaphore, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to semaphore events.
Definition event_loop.c:394
void furi_event_loop_run(FuriEventLoop *instance)
Continuously poll for events.
Definition event_loop.c:203
void furi_event_loop_subscribe_event_flag(FuriEventLoop *instance, FuriEventFlag *event_flag, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to event flag events.
Definition event_loop.c:359
void furi_event_loop_pend_callback(FuriEventLoop *instance, FuriEventLoopPendingCallback callback, void *context)
Call a function when all preceding timer commands are processed.
Definition event_loop.c:288
bool furi_event_loop_is_subscribed(FuriEventLoop *instance, FuriEventLoopObject *object)
Checks if the loop is subscribed to an object of any kind.
Definition event_loop.c:460
void furi_event_loop_unsubscribe(FuriEventLoop *instance, FuriEventLoopObject *object)
Unsubscribe from events (common)
Definition event_loop.c:422
void furi_event_loop_free(FuriEventLoop *instance)
Free Event Loop instance.
Definition event_loop.c:81
void furi_event_loop_stop(FuriEventLoop *instance)
Stop Event Loop instance.
Definition event_loop.c:279
FuriEventLoop * furi_event_loop_alloc(void)
Allocate Event Loop instance.
Definition event_loop.c:62
void furi_event_loop_subscribe_mutex(FuriEventLoop *instance, FuriMutex *mutex, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to mutex events.
Definition event_loop.c:406
void furi_event_loop_subscribe_message_queue(FuriEventLoop *instance, FuriMessageQueue *message_queue, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to message queue events.
Definition event_loop.c:370
void(* FuriEventLoopPendingCallback)(void *context)
Timer callback type for functions to be called in a deferred manner.
Definition event_loop.h:177
FuriEventLoopEvent
Enumeration of event types, flags and masks.
Definition event_loop.h:35
@ FuriEventLoopEventFlagEdge
Use edge triggered events.
Definition event_loop.h:86
@ FuriEventLoopEventIn
Subscribe to In events.
Definition event_loop.h:45
@ FuriEventLoopEventFlagMask
Special value containing the event flag bits, used internally.
Definition event_loop.h:98
@ FuriEventLoopEventOut
Subscribe to Out events.
Definition event_loop.h:55
@ FuriEventLoopEventFlagOnce
Automatically unsubscribe from events after one time.
Definition event_loop.h:94
@ FuriEventLoopEventMask
Special value containing the event direction bits, used internally.
Definition event_loop.h:59
@ FuriEventLoopEventReserved
Special value to force the enum to 32-bit values.
Definition event_loop.h:102
void(* FuriEventLoopEventCallback)(FuriEventLoopObject *object, void *context)
Callback type for event loop events.
Definition event_loop.h:204
void(* FuriEventLoopTickCallback)(void *context)
Tick callback type.
Definition event_loop.h:147
void furi_event_loop_tick_set(FuriEventLoop *instance, uint32_t interval, FuriEventLoopTickCallback callback, void *context)
Set Event Loop tick callback.
Definition event_loop_tick.c:56
Definition event_flag.c:14
Definition event_loop_i.h:78
Definition message_queue.c:16
Definition mutex.c:13
Definition semaphore.c:15
Definition stream_buffer.c:14