Remove explicit app closing function (#618)

This commit is contained in:
Ken Van Hoeylandt
2026-08-21 08:59:52 +02:00
committed by GitHub
parent 0ff1627385
commit 4fea48f433
50 changed files with 19 additions and 89 deletions
+8 -3
View File
@@ -156,9 +156,9 @@ void app_task_main(void* context) {
deliver_result_to_parent_if_any(ctx->app_instance_id, result);
// A safe default terminal marker for CLOSE (and any other exit): an app that calls
// app_manager_finish() already marked itself Stopped before returning, so this is a no-op
// for it - but it's still needed as the terminal marker for any other exit path.
// The terminal marker for every exit path: an app instance is Stopped exactly when its
// AppMainFn/AppLoaderApi::run() has returned, whether that return was self-initiated or in
// response to APP_EVENT_CLOSE.
set_state(ctx->app_instance_id, APP_INSTANCE_STATE_STOPPED);
app_ledger_free_arguments(ctx->argc, ctx->argv);
@@ -269,6 +269,11 @@ error_t app_scheduler_stop(AppInstanceId app_instance_id, TickType_t join_timeou
AppEvent event { .type = APP_EVENT_CLOSE, .timestamp = 0, .result = {} };
app_event_emit(app_instance_id, &event);
// Marked as soon as the app has been told to close, not once its task has actually
// unwound - so app_manager_get_state()/app_manager_get_topmost_instance_id() reflect the
// closure immediately, without waiting on whatever teardown the app still has left to do.
set_state(app_instance_id, APP_INSTANCE_STATE_STOPPING);
// Blocks until app_task_main() gives this dedicated semaphore as the literal last thing it does before vTaskDelete().
// Uses aa dedicated semaphore rather than this task's default FreeRTOS notification because app_event.cpp's AppEventSubscription also uses that shared slot.
// An unrelated event (e.g. a different child's APP_EVENT_RESULT) delivered to this same task could otherwise unblock this early.
-11
View File
@@ -138,17 +138,6 @@ error_t app_manager_stop(AppInstanceId app_instance_id) {
return app_scheduler_stop(app_instance_id, pdMS_TO_TICKS(2000));
}
error_t app_manager_finish(AppInstanceId app_instance_id) {
auto& ledger = app_ledger();
mutex_lock(&ledger.mutex);
auto iterator = ledger.instances.find(app_instance_id);
if (iterator != ledger.instances.end()) {
iterator->second.state = APP_INSTANCE_STATE_STOPPED;
}
mutex_unlock(&ledger.mutex);
return ERROR_NONE;
}
AppInstanceState app_manager_get_state(AppInstanceId app_instance_id) {
auto& ledger = app_ledger();
mutex_lock(&ledger.mutex);
-1
View File
@@ -30,7 +30,6 @@ const ModuleSymbol app_module_symbols[] = {
DEFINE_MODULE_SYMBOL(app_manager_start_with_parameters),
DEFINE_MODULE_SYMBOL(app_manager_start_for_result),
DEFINE_MODULE_SYMBOL(app_manager_stop),
DEFINE_MODULE_SYMBOL(app_manager_finish),
DEFINE_MODULE_SYMBOL(app_manager_get_state),
DEFINE_MODULE_SYMBOL(app_manager_find_manifest),
DEFINE_MODULE_SYMBOL(app_manager_for_each_manifest),