parent
8c5e048b7c
commit
3c538b44ac
13 changed files with 98 additions and 98 deletions
@ -1,15 +1,37 @@ |
||||
use { |
||||
super::*, |
||||
tokio::sync::Mutex, |
||||
tokio::sync::{ |
||||
Mutex, |
||||
MutexGuard |
||||
}, |
||||
std::sync::Arc, |
||||
std::collections::HashMap, |
||||
uuid::Uuid, |
||||
crate::client::* |
||||
}; |
||||
|
||||
|
||||
pub type JobPool = Vec<Box<dyn Job>>; |
||||
//pub type JobPool = Vec<Box<dyn Job>>;
|
||||
pub type JobPool = Vec<ShellJob>; |
||||
pub type JobResult = Result<Vec<u8>, Vec<u8>>; |
||||
|
||||
pub type CliStorage = HashMap<Uuid, UClient>; |
||||
pub type SharedStorage = Arc<Mutex<CliStorage>>; |
||||
|
||||
|
||||
#[derive(Clone)] |
||||
pub struct Storage { |
||||
clients: Arc<Mutex<CliStorage>> |
||||
} |
||||
|
||||
impl Storage { |
||||
pub fn new() -> Self { |
||||
Self { |
||||
clients: Arc::new( |
||||
Mutex::new(HashMap::<Uuid, UClient>::new()) |
||||
) |
||||
} |
||||
} |
||||
|
||||
pub async fn lock(&self) -> MutexGuard<'_, CliStorage> { |
||||
self.clients.lock().await |
||||
} |
||||
} |
Loading…
Reference in new issue