ext-workspace: implement v1
This commit is contained in:
parent
2b76083d6e
commit
a4e197d92a
22 changed files with 948 additions and 4 deletions
27
src/utils/opt.rs
Normal file
27
src/utils/opt.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use {crate::utils::clonecell::CloneCell, std::rc::Rc};
|
||||
|
||||
pub struct Opt<T> {
|
||||
t: CloneCell<Option<Rc<T>>>,
|
||||
}
|
||||
|
||||
impl<T> Default for Opt<T> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
t: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Opt<T> {
|
||||
pub fn set(&self, t: Option<Rc<T>>) {
|
||||
self.t.set(t);
|
||||
}
|
||||
|
||||
pub fn get(&self) -> Option<Rc<T>> {
|
||||
self.t.get()
|
||||
}
|
||||
|
||||
pub fn is_none(&self) -> bool {
|
||||
self.t.is_none()
|
||||
}
|
||||
}
|
||||
|
|
@ -53,4 +53,10 @@ impl<T> SyncQueue<T> {
|
|||
self.swap(&mut res);
|
||||
res
|
||||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
unsafe {
|
||||
self.el.get().deref_mut().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue