1
0
Fork 0
forked from wry/wry

autocommit 2022-03-09 17:51:17 CET

This commit is contained in:
Julian Orth 2022-03-09 17:51:17 +01:00
parent 4df6b559b7
commit 0399772467
35 changed files with 429 additions and 423 deletions

29
src/utils/syncqueue.rs Normal file
View file

@ -0,0 +1,29 @@
use std::cell::UnsafeCell;
use std::collections::VecDeque;
use crate::utils::ptr_ext::MutPtrExt;
pub struct SyncQueue<T> {
el: UnsafeCell<VecDeque<T>>,
}
impl<T> Default for SyncQueue<T> {
fn default() -> Self {
Self {
el: Default::default(),
}
}
}
impl<T> SyncQueue<T> {
pub fn push(&self, t: T) {
unsafe {
self.el.get().deref_mut().push_back(t);
}
}
pub fn pop(&self) -> Option<T> {
unsafe {
self.el.get().deref_mut().pop_front()
}
}
}