Skip to main content

Mountain/Binary/Shutdown/
RuntimeShutdown.rs

1//! # Runtime Shutdown Module
2//!
3//! Handles graceful shutdown of the ApplicationRunTime.
4
5use std::sync::Arc;
6
7use tauri::Manager;
8
9use crate::{RunTime::ApplicationRunTime::ApplicationRunTime, dev_log};
10
11/// Shuts down the ApplicationRunTime and its effect execution engine.
12///
13/// # Arguments
14///
15/// * `ApplicationHandle` - The Tauri application handle
16///
17/// # Returns
18///
19/// A `Result` indicating success or failure.
20///
21/// # Shutdown Process
22///
23/// This function performs:
24/// - Stops all running tasks and effects
25/// - Cleans up internal resources
26/// - Ensures graceful termination of the runtime
27///
28/// # Errors
29///
30/// Returns an error if ApplicationRunTime is not found or shutdown fails.
31pub async fn RuntimeShutdown(ApplicationHandle:&tauri::AppHandle) -> Result<(), String> {
32	dev_log!("lifecycle", "[Shutdown] [Runtime] Shutting down ApplicationRunTime...");
33
34	let RunTime = ApplicationHandle.state::<Arc<ApplicationRunTime>>().inner().clone();
35
36	RunTime.Shutdown().await;
37
38	dev_log!("lifecycle", "[Shutdown] [Runtime] ApplicationRunTime stopped.");
39
40	Ok(())
41}