mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 17:48:35 -07:00
Toolbox: Add run_parallel() util
Runs a self-cleaning-up thread without boilerplate Same paradigm used in existing code like region and rpc services Not replaced there to avoid merge conflicts Not exposed to API for now
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
#include <cli/cli.h>
|
||||
#include <toolbox/run_parallel.h>
|
||||
|
||||
#include "test_runner.h"
|
||||
|
||||
@@ -13,21 +14,14 @@ void unit_tests_cli(Cli* cli, FuriString* args, void* context) {
|
||||
test_runner_free(test_runner);
|
||||
}
|
||||
|
||||
static void unit_tests_pending(void* context, uint32_t arg) {
|
||||
UNUSED(arg);
|
||||
FuriThread* thread = context;
|
||||
furi_thread_join(thread);
|
||||
furi_thread_free(thread);
|
||||
}
|
||||
|
||||
static int32_t unit_tests_thread(void* context) {
|
||||
UNUSED(context);
|
||||
furi_delay_ms(5000);
|
||||
FuriString* args = furi_string_alloc();
|
||||
TestRunner* test_runner = test_runner_alloc(NULL, args);
|
||||
test_runner_run(test_runner);
|
||||
test_runner_free(test_runner);
|
||||
furi_string_free(args);
|
||||
furi_timer_pending_callback(unit_tests_pending, context, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -38,8 +32,6 @@ void unit_tests_on_system_start(void) {
|
||||
furi_record_close(RECORD_CLI);
|
||||
#endif
|
||||
if(furi_hal_is_normal_boot()) {
|
||||
FuriThread* thread = furi_thread_alloc_ex("UnitTests", 4 * 1024, unit_tests_thread, NULL);
|
||||
furi_thread_set_context(thread, thread);
|
||||
furi_thread_start(thread);
|
||||
run_parallel(unit_tests_thread, NULL, 4 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user