From aba20b6af8eb15e23ff544cf29dfa77207695aea Mon Sep 17 00:00:00 2001 From: Sergey Gavrilov Date: Thu, 29 Sep 2022 20:42:15 +1000 Subject: [PATCH] Furi Thread: fixed furi_thread_join, check if thread has not been started (#1803) * furi thread: fixed furi_thread_join, check if thread has not been started * Furi: correct returns in furi_thread_join Co-authored-by: Aleksandr Kutuzov --- furi/core/thread.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/furi/core/thread.c b/furi/core/thread.c index 538ae4d8..d326e389 100644 --- a/furi/core/thread.c +++ b/furi/core/thread.c @@ -209,11 +209,17 @@ bool furi_thread_join(FuriThread* thread) { furi_check(furi_thread_get_current() != thread); + // Check if thread was started + if(thread->task_handle == NULL) { + return false; + } + + // Wait for thread to stop while(eTaskGetState(thread->task_handle) != eDeleted) { furi_delay_ms(10); } - return FuriStatusOk; + return true; } FuriThreadId furi_thread_get_id(FuriThread* thread) {