mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
[FL-3847, FL-3513] Thread Signals (#3730)
* Add signal API * Add signal support to loader * Add signal support to ViewDispatcher * Remove extra signal definitions * Fix typos Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> * scripts: runfap: close current app pre-launch * loader: enable backlight when starting an app * scripts: removed distfap.py * Do not expose signal API via ViewDispatcher * scripts: runfap: iterative retry to launch * Add a loader signal subcommand * Furi, Gui: move signal handling from View Dispatcher to Event Loop Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su> Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -42,6 +42,9 @@ struct FuriThread {
|
||||
FuriThreadStateCallback state_callback;
|
||||
void* state_context;
|
||||
|
||||
FuriThreadSignalCallback signal_callback;
|
||||
void* signal_context;
|
||||
|
||||
char* name;
|
||||
char* appid;
|
||||
|
||||
@@ -304,6 +307,29 @@ FuriThreadState furi_thread_get_state(FuriThread* thread) {
|
||||
return thread->state;
|
||||
}
|
||||
|
||||
void furi_thread_set_signal_callback(
|
||||
FuriThread* thread,
|
||||
FuriThreadSignalCallback callback,
|
||||
void* context) {
|
||||
furi_check(thread);
|
||||
furi_check(thread->state == FuriThreadStateStopped || thread == furi_thread_get_current());
|
||||
|
||||
thread->signal_callback = callback;
|
||||
thread->signal_context = context;
|
||||
}
|
||||
|
||||
bool furi_thread_signal(const FuriThread* thread, uint32_t signal, void* arg) {
|
||||
furi_check(thread);
|
||||
|
||||
bool is_consumed = false;
|
||||
|
||||
if(thread->signal_callback) {
|
||||
is_consumed = thread->signal_callback(signal, arg, thread->signal_context);
|
||||
}
|
||||
|
||||
return is_consumed;
|
||||
}
|
||||
|
||||
void furi_thread_start(FuriThread* thread) {
|
||||
furi_check(thread);
|
||||
furi_check(thread->callback);
|
||||
|
||||
Reference in New Issue
Block a user