mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
ephemeral logins
This commit is contained in:
9
core/startos/src/util/sync.rs
Normal file
9
core/startos/src/util/sync.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
pub struct SyncMutex<T>(std::sync::Mutex<T>);
|
||||
impl<T> SyncMutex<T> {
|
||||
pub fn new(t: T) -> Self {
|
||||
Self(std::sync::Mutex::new(t))
|
||||
}
|
||||
pub fn mutate<F: FnOnce(&mut T) -> U, U>(&self, f: F) -> U {
|
||||
f(&mut *self.0.lock().unwrap())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user