DEV Community

RwLock HashMap Arc Mutex File

pub struct Context {
    pub(crate) tools: HashMap<String, Option<PathBuf>>,
    pub(crate) fifos: tokio::sync::RwLock<HashMap<String, Arc<Mutex<File>>>>,
 //                                ^                      ^   ^
}//          many fifos, but only  |    async ref counter |   | but only one will
 //           one active at a time |    because many file |   | be active at a time
 //                                |    refs could exist      


Enter fullscreen mode Exit fullscreen mode

Top comments (0)