All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
210typedef void (*FuriEventLoopThreadFlagsCallback)(void* context);
211
213typedef struct FuriEventFlag FuriEventFlag;
214
227 FuriEventLoop* instance,
228 FuriEventFlag* event_flag,
229 FuriEventLoopEvent event,
231 void* context);
232
235
247 FuriEventLoop* instance,
248 FuriMessageQueue* message_queue,
249 FuriEventLoopEvent event,
251 void* context);
252
255
267 FuriEventLoop* instance,
268 FuriStreamBuffer* stream_buffer,
269 FuriEventLoopEvent event,
271 void* context);
272
275
287 FuriEventLoop* instance,
288 FuriSemaphore* semaphore,
289 FuriEventLoopEvent event,
291 void* context);
292
294typedef struct FuriMutex FuriMutex;
295
307 FuriEventLoop* instance,
308 FuriMutex* mutex,
309 FuriEventLoopEvent event,
311 void* context);
312
320 FuriEventLoop* instance,
322 void* context);
323
329
335void furi_event_loop_unsubscribe(FuriEventLoop* instance, FuriEventLoopObject* object);
336
343bool furi_event_loop_is_subscribed(FuriEventLoop* instance, FuriEventLoopObject* object);
344
348static inline void
349 furi_event_loop_maybe_unsubscribe(FuriEventLoop* instance, FuriEventLoopObject* object) {
350 if(furi_event_loop_is_subscribed(instance, object))
351 furi_event_loop_unsubscribe(instance, object);
352}
353
354#ifdef __cplusplus
355}
356#endif
void furi_event_loop_subscribe_thread_flags(FuriEventLoop *instance, FuriEventLoopThreadFlagsCallback callback, void *context)
Subscribe to thread flag events of the current thread.
Definition event_loop.c:424
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:388
void furi_event_loop_subscribe_semaphore(FuriEventLoop *instance, FuriSemaphore *semaphore, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to semaphore events.
Definition event_loop.c:400
void furi_event_loop_run(FuriEventLoop *instance)
Continuously poll for events.
Definition event_loop.c:208
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:365
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:294
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:484
void furi_event_loop_unsubscribe(FuriEventLoop *instance, FuriEventLoopObject *object)
Unsubscribe from events (common)
Definition event_loop.c:446
void furi_event_loop_free(FuriEventLoop *instance)
Free Event Loop instance.
Definition event_loop.c:73
void furi_event_loop_stop(FuriEventLoop *instance)
Stop Event Loop instance.
Definition event_loop.c:285
FuriEventLoop * furi_event_loop_alloc(void)
Allocate Event Loop instance.
Definition event_loop.c:54
void furi_event_loop_subscribe_mutex(FuriEventLoop *instance, FuriMutex *mutex, FuriEventLoopEvent event, FuriEventLoopEventCallback callback, void *context)
Subscribe to mutex events.
Definition event_loop.c:412
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:376
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_unsubscribe_thread_flags(FuriEventLoop *instance)
Unsubscribe from thread flag events of the current thread.
Definition event_loop.c:436
void(* FuriEventLoopThreadFlagsCallback)(void *context)
Callback type for event loop thread flag events.
Definition event_loop.h:210
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:80
Definition message_queue.c:16
Definition mutex.c:13
Definition semaphore.c:15
Definition stream_buffer.c:14