autocommit 2022-03-26 22:58:30 CET
This commit is contained in:
parent
3b1b843821
commit
707ff6066c
28 changed files with 2307 additions and 707 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::utils::ptr_ext::MutPtrExt;
|
||||
use std::cell::UnsafeCell;
|
||||
use std::collections::VecDeque;
|
||||
use std::mem;
|
||||
|
||||
pub struct SyncQueue<T> {
|
||||
el: UnsafeCell<VecDeque<T>>,
|
||||
|
|
@ -28,4 +29,10 @@ impl<T> SyncQueue<T> {
|
|||
pub fn is_empty(&self) -> bool {
|
||||
unsafe { self.el.get().deref_mut().is_empty() }
|
||||
}
|
||||
|
||||
pub fn swap(&self, queue: &mut VecDeque<T>) {
|
||||
unsafe {
|
||||
mem::swap(self.el.get().deref_mut(), queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue