diff options
Diffstat (limited to 'splorm/src/state.rs')
| -rw-r--r-- | splorm/src/state.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/splorm/src/state.rs b/splorm/src/state.rs index 12ef5d9..59e8629 100644 --- a/splorm/src/state.rs +++ b/splorm/src/state.rs @@ -1,2 +1,33 @@ -#[derive(Clone, Debug)] -pub struct SplormState {} +use std::sync::Arc; + +use tokio::sync::{Mutex, MutexGuard}; + +use crate::connector::GathererThread; + +#[derive(Clone)] +pub struct SplormState { + connectors: ConnectorsState, +} + +impl SplormState { + pub fn new(connectors: ConnectorsState) -> Self { + Self { connectors } + } + + pub async fn gatherer_thread<'s>(&'s self) -> MutexGuard<'s, GathererThread> { + self.connectors.gatherer.lock().await + } +} + +#[derive(Clone)] +pub struct ConnectorsState { + gatherer: Arc<Mutex<GathererThread>>, +} + +impl ConnectorsState { + pub fn new(gatherer: GathererThread) -> Self { + Self { + gatherer: Arc::new(Mutex::new(gatherer)), + } + } +} |
