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::frag::FragTonnetz;
10use crate::orcha::Orchestrator;
11use crate::scheduler::Scheduler;
12use crate::types::{PerformanceTracker, SystemInfo};
13use rstmt::nrt::Triad;
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> Default for Runtime<D>
38where
39    D: Driver<Triad>,
40{
41    fn default() -> Self {
42        Self::new()
43    }
44}
45
46impl<D> Runtime<D>
47where
48    D: Driver<Triad>,
49{
50    pub fn new() -> Self {
51        Self {
52            inner: Arc::new(RuntimeInner::new()),
53        }
54    }
55}
56
57impl<D> Clone for Runtime<D>
58where
59    D: Driver<Triad>,
60{
61    fn clone(&self) -> Self {
62        Self {
63            inner: Arc::clone(&self.inner),
64        }
65    }
66}
67
68impl<D> core::ops::Deref for Runtime<D>
69where
70    D: Driver<Triad>,
71{
72    type Target = RuntimeInner<D>;
73
74    fn deref(&self) -> &Self::Target {
75        &self.inner
76    }
77}
78
79impl<D> core::ops::DerefMut for Runtime<D>
80where
81    D: Driver<Triad>,
82{
83    fn deref_mut(&mut self) -> &mut Self::Target {
84        Arc::make_mut(&mut self.inner)
85    }
86}