mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* add loggedIn key to sessions * show loggedIn timestamp in list * don't double hash active session --------- Co-authored-by: Aiden McClelland <me@drbonez.dev>
13 lines
359 B
Rust
13 lines
359 B
Rust
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())
|
|
}
|
|
pub fn peek<F: FnOnce(&T) -> U, U>(&self, f: F) -> U {
|
|
f(&*self.0.lock().unwrap())
|
|
}
|
|
}
|