Flipper Zero Firmware
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "base.h"
9#include "common_defines.h"
10
11#include <stdint.h>
12#include <stddef.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
28
43
47typedef struct FuriThread FuriThread;
48
51
55typedef void* FuriThreadId;
56
65typedef int32_t (*FuriThreadCallback)(void* context);
66
77typedef void (*FuriThreadStdoutWriteCallback)(const char* data, size_t size);
78
87typedef void (*FuriThreadStateCallback)(FuriThreadState state, void* context);
88
99typedef bool (*FuriThreadSignalCallback)(uint32_t signal, void* arg, void* context);
100
107
125 const char* name,
126 uint32_t stack_size,
127 FuriThreadCallback callback,
128 void* context);
129
140 const char* name,
141 uint32_t stack_size,
142 FuriThreadCallback callback,
143 void* context);
144
154void furi_thread_free(FuriThread* thread);
155
164void furi_thread_set_name(FuriThread* thread, const char* name);
165
177void furi_thread_set_appid(FuriThread* thread, const char* appid);
178
188void furi_thread_set_stack_size(FuriThread* thread, size_t stack_size);
189
199
208void furi_thread_set_context(FuriThread* thread, void* context);
209
219
227
234
241
251
260void furi_thread_set_state_context(FuriThread* thread, void* context);
261
269
280 FuriThread* thread,
282 void* context);
283
291bool furi_thread_signal(const FuriThread* thread, uint32_t signal, void* arg);
292
300void furi_thread_start(FuriThread* thread);
301
313bool furi_thread_join(FuriThread* thread);
314
322
331
340
350
362
369
376
380void furi_thread_yield(void);
381
391uint32_t furi_thread_flags_set(FuriThreadId thread_id, uint32_t flags);
392
399uint32_t furi_thread_flags_clear(uint32_t flags);
400
405uint32_t furi_thread_flags_get(void);
406
417uint32_t furi_thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeout);
418
426bool furi_thread_enumerate(FuriThreadList* thread_list);
427
434const char* furi_thread_get_name(FuriThreadId thread_id);
435
442const char* furi_thread_get_appid(FuriThreadId thread_id);
443
450uint32_t furi_thread_get_stack_space(FuriThreadId thread_id);
451
458
464
471size_t furi_thread_stdout_write(const char* data, size_t size);
472
478int32_t furi_thread_stdout_flush(void);
479
487void furi_thread_suspend(FuriThreadId thread_id);
488
494void furi_thread_resume(FuriThreadId thread_id);
495
503
504#ifdef __cplusplus
505}
506#endif
Definition thread.c:32
void(* FuriThreadStateCallback)(FuriThreadState state, void *context)
State change callback function pointer type.
Definition thread.h:87
bool furi_thread_join(FuriThread *thread)
Wait for a FuriThread to exit.
Definition thread.c:367
void furi_thread_enable_heap_trace(FuriThread *thread)
Enable heap usage tracing for a FuriThread.
Definition thread.c:390
void furi_thread_set_stack_size(FuriThread *thread, size_t stack_size)
Set the stack size of a FuriThread instance.
Definition thread.c:240
uint32_t furi_thread_get_stack_space(FuriThreadId thread_id)
Get thread stack watermark.
Definition thread.c:673
FuriThreadPriority furi_thread_get_priority(FuriThread *thread)
Get the priority of a FuriThread.
Definition thread.c:276
FuriThreadPriority furi_thread_get_current_priority(void)
Get the priority of the current FuriThread.
Definition thread.c:289
FuriThread * furi_thread_alloc_ex(const char *name, uint32_t stack_size, FuriThreadCallback callback, void *context)
Create a FuriThread instance w/ extra parameters.
Definition thread.c:186
void furi_thread_set_name(FuriThread *thread, const char *name)
Set the name of a FuriThread instance.
Definition thread.c:218
void furi_thread_suspend(FuriThreadId thread_id)
Suspend a thread.
Definition thread.c:750
bool(* FuriThreadSignalCallback)(uint32_t signal, void *arg, void *context)
Signal handler callback function pointer type.
Definition thread.h:99
uint32_t furi_thread_flags_set(FuriThreadId thread_id, uint32_t flags)
Set the thread flags of a FuriThread.
Definition thread.c:435
FuriThreadState
Enumeration of possible FuriThread states.
Definition thread.h:23
@ FuriThreadStateRunning
Thread is running.
Definition thread.h:26
@ FuriThreadStateStarting
Thread is starting.
Definition thread.h:25
@ FuriThreadStateStopped
Thread is stopped.
Definition thread.h:24
void(* FuriThreadStdoutWriteCallback)(const char *data, size_t size)
Standard output callback function pointer type.
Definition thread.h:77
uint32_t furi_thread_flags_get(void)
Get the thread flags of the current FuriThread.
Definition thread.c:491
FuriThread * furi_thread_get_current(void)
Get the FuriThread instance associated with the current thread.
Definition thread.c:418
size_t furi_thread_stdout_write(const char *data, size_t size)
Write data to buffered standard output.
Definition thread.c:718
uint32_t furi_thread_flags_clear(uint32_t flags)
Clear the thread flags of the current FuriThread.
Definition thread.c:462
void furi_thread_resume(FuriThreadId thread_id)
Resume a thread.
Definition thread.c:758
const char * furi_thread_get_name(FuriThreadId thread_id)
Get the name of a thread based on its unique identifier.
Definition thread.c:646
void furi_thread_set_context(FuriThread *thread, void *context)
Set the callback function context.
Definition thread.c:263
bool furi_thread_enumerate(FuriThreadList *thread_list)
Enumerate all threads.
Definition thread.c:598
uint32_t furi_thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeout)
Wait for some thread flags to be set.
Definition thread.c:509
size_t furi_thread_get_heap_size(FuriThread *thread)
Get heap usage by a FuriThread instance.
Definition thread.c:402
FuriThreadId furi_thread_get_current_id(void)
Get the unique identifier of the current FuriThread.
Definition thread.c:414
void furi_thread_set_state_context(FuriThread *thread, void *context)
Set the state change callback context.
Definition thread.c:299
FuriThreadPriority
Enumeration of possible FuriThread priorities.
Definition thread.h:32
@ FuriThreadPriorityLowest
Lowest.
Definition thread.h:35
@ FuriThreadPriorityNormal
Normal.
Definition thread.h:37
@ FuriThreadPriorityNone
Uninitialized, choose system default.
Definition thread.h:33
@ FuriThreadPriorityHigh
High.
Definition thread.h:38
@ FuriThreadPriorityHighest
Highest.
Definition thread.h:39
@ FuriThreadPriorityLow
Low.
Definition thread.h:36
@ FuriThreadPriorityIdle
Idle priority.
Definition thread.h:34
@ FuriThreadPriorityIsr
Deferred ISR (highest possible)
Definition thread.h:40
FuriThread * furi_thread_alloc_service(const char *name, uint32_t stack_size, FuriThreadCallback callback, void *context)
Create a FuriThread instance (service mode).
Definition thread.c:166
void furi_thread_set_stdout_callback(FuriThreadStdoutWriteCallback callback)
Set standard output callback for the current thread.
Definition thread.c:705
struct FuriThreadList FuriThreadList
FuriThreadList type.
Definition thread.h:50
void furi_thread_set_callback(FuriThread *thread, FuriThreadCallback callback)
Set the user callback function to be executed in a FuriThread.
Definition thread.c:257
FuriThreadState furi_thread_get_state(FuriThread *thread)
Get the state of a FuriThread isntance.
Definition thread.c:305
void furi_thread_set_appid(FuriThread *thread, const char *appid)
Set the application ID of a FuriThread instance.
Definition thread.c:229
void furi_thread_yield(void)
Return control to the scheduler.
Definition thread.c:423
void furi_thread_free(FuriThread *thread)
Delete a FuriThread instance.
Definition thread.c:199
int32_t furi_thread_get_return_code(FuriThread *thread)
Get the return code of a FuriThread instance.
Definition thread.c:408
void furi_thread_set_priority(FuriThread *thread, FuriThreadPriority priority)
Set the priority of a FuriThread.
Definition thread.c:269
FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback(void)
Get the standard output callback for the current thead.
Definition thread.c:712
void * FuriThreadId
Unique thread identifier type (used by the OS kernel).
Definition thread.h:55
int32_t furi_thread_stdout_flush(void)
Flush buffered data to standard output.
Definition thread.c:743
void furi_thread_set_signal_callback(FuriThread *thread, FuriThreadSignalCallback callback, void *context)
Set a signal handler callback for a FuriThread instance.
Definition thread.c:310
const char * furi_thread_get_appid(FuriThreadId thread_id)
Get the application id of a thread based on its unique identifier.
Definition thread.c:659
void furi_thread_set_state_callback(FuriThread *thread, FuriThreadStateCallback callback)
Set the callback function to be executed upon a state thransition of a FuriThread.
Definition thread.c:293
FuriThreadId furi_thread_get_id(FuriThread *thread)
Get the unique identifier of a FuriThread instance.
Definition thread.c:385
int32_t(* FuriThreadCallback)(void *context)
Thread callback function pointer type.
Definition thread.h:65
FuriThread * furi_thread_alloc(void)
Create a FuriThread instance.
Definition thread.c:158
void furi_thread_disable_heap_trace(FuriThread *thread)
Disable heap usage tracing for a FuriThread.
Definition thread.c:396
bool furi_thread_signal(const FuriThread *thread, uint32_t signal, void *arg)
Send a signal to a FuriThread instance.
Definition thread.c:321
void furi_thread_set_current_priority(FuriThreadPriority priority)
Set the priority of the current FuriThread.
Definition thread.c:282
void furi_thread_start(FuriThread *thread)
Start a FuriThread instance.
Definition thread.c:333
bool furi_thread_is_suspended(FuriThreadId thread_id)
Test if a thread is suspended.
Definition thread.c:770