xref: /DragonReach/src/executor/mod.rs (revision e5a8055aa517085cf10def70e7fddab4ec87fd13)
1 #[cfg(target_os = "dragonos")]
2 use drstd as std;
3 
4 pub mod dep_graph;
5 pub mod service_executor;
6 
7 use std::process::Child;
8 use std::sync::Arc;
9 
10 use crate::{
11     error::runtime_error::{RuntimeError, RuntimeErrorType},
12     unit::Unit,
13 };
14 
15 use self::dep_graph::DepGraph;
16 
17 //Unit的全局执行器
18 pub struct Executor;
19 
20 impl Executor {
21     pub fn exec(unit: &Arc<dyn Unit>) -> Result<(), RuntimeError> {
22         //TODO: 优化此处,解析时也用到了拓扑排序,尝试使用那次拓扑排序的结果
23         let mut graph = DepGraph::construct_graph(unit);
24 
25         let sort_ret = graph.topological_sort()?;
26 
27         for u in sort_ret {
28             if let Err(e) = u.run() {
29                 return Err(e);
30             }
31         }
32 
33         return Ok(());
34     }
35 }
36