use std::sync::*;
pub trait Notifiable : Sync+Send {
fn mark_as_changed(&self);
}
pub trait Releasable : Send {
fn keep_alive(&mut self);
fn done(&mut self);
}
pub trait Changeable {
fn when_changed(&self, what: Arc<dyn Notifiable>) -> Box<dyn Releasable>;
}
pub trait Bound<Value> : Changeable+Send+Sync {
fn get(&self) -> Value;
}
pub trait WithBound<Value>: Changeable + Send + Sync {
fn with_ref<F, T>(&self, f: F) -> T
where
F: FnOnce(&Value) -> T;
fn with_mut<F>(&self, f: F)
where
F: FnOnce(&mut Value) -> bool;
}
pub trait MutableBound<Value> : Bound<Value> {
fn set(&self, new_value: Value);
}