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