eryon_rt/
runtime.rs

1/*
2    Appellation: runtime <module>
3    Contrib: @FL03
4*/
5
6mod impl_inner;
7
8use crate::actors::drivers::Driver;
9use crate::fragment::FragTonnetz;
10use crate::nrt::Triad;
11use crate::orcha::Orchestrator;
12use crate::scheduler::Scheduler;
13use crate::types::{PerformanceTracker, SystemInfo};
14use std::sync::Arc;
15
16/// The Runtime manages the local fragment of the tonnetz and provides
17/// methods for executing tasks and coordinating between partitions.
18pub struct Runtime<D>
19where
20    D: Driver<Triad>,
21{
22    pub(crate) inner: Arc<RuntimeInner<D>>,
23}
24
25#[derive(Clone, Debug)]
26pub struct RuntimeInner<D>
27where
28    D: Driver<Triad>,
29{
30    pub(crate) fragment: FragTonnetz<D>,
31    pub(crate) orchestrator: Orchestrator,
32    pub(crate) scheduler: Scheduler,
33    pub(crate) system_info: SystemInfo,
34    pub(crate) perf_tracker: PerformanceTracker,
35}
36
37impl<D> Runtime<D>
38where
39    D: Driver<Triad>,
40{
41    pub fn new() -> Self {
42        Self {
43            inner: Arc::new(RuntimeInner::new()),
44        }
45    }
46}
47
48impl<D> Clone for Runtime<D>
49where
50    D: Driver<Triad>,
51{
52    fn clone(&self) -> Self {
53        Self {
54            inner: Arc::clone(&self.inner),
55        }
56    }
57}
58
59impl<D> core::ops::Deref for Runtime<D>
60where
61    D: Driver<Triad>,
62{
63    type Target = RuntimeInner<D>;
64
65    fn deref(&self) -> &Self::Target {
66        &self.inner
67    }
68}
69
70impl<D> core::ops::DerefMut for Runtime<D>
71where
72    D: Driver<Triad>,
73{
74    fn deref_mut(&mut self) -> &mut Self::Target {
75        Arc::make_mut(&mut self.inner)
76    }
77}