State management
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
pub module state_management;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::LockResult;
|
||||
use std::sync::MutexGuard;
|
||||
|
||||
pub trait Dependent
|
||||
{
|
||||
void update(&self);
|
||||
}
|
||||
|
||||
pub struct State<T>
|
||||
{
|
||||
pub Box<dyn Dependent> dependent;
|
||||
pub Arc<Mutex<T>> data;
|
||||
}
|
||||
|
||||
impl<T> State<T>
|
||||
{
|
||||
LockResult<MutexGuard<'_, T>> lock(&self)
|
||||
{
|
||||
self.data.lock()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user