#[derive(Debug)]
pub struct CcQueue<T, A: Allocator>(NonNull<QueueInternal<T, A>>);
unsafe impl<T, A: Allocator> Send for CcQueue<T, A>
{
}
unsafe impl<T, A: Allocator> Sync for CcQueue<T, A>
{
}
impl<T, A: Allocator> AllocatorOpened<A> for CcQueue<T, A>
{
#[inline(always)]
fn allocator_opened(&mut self, allocator: A)
{
unsafe { self.0.as_mut() }.allocator_opened(allocator)
}
}
impl<T, A: Allocator> Drop for CcQueue<T, A>
{
#[inline(always)]
fn drop(&mut self)
{
let queue_internal = self.0;
let allocator = unsafe { self.0.as_ref() }.allocator().clone();
unsafe { drop_in_place(queue_internal.as_ptr()) };
QueueInternal::free_after_drop(queue_internal, allocator);
}
}
impl<T, A: Allocator> CcQueue<T, A>
{
#[inline(always)]
pub fn new(allocator: A) -> Self
{
CcQueue(QueueInternal::new(allocator))
}
#[inline(always)]
pub fn new_per_thread_handle<'queue>(&'queue self) -> PerQueueThreadHandle<'queue, T, A>
{
PerQueueThreadHandle(self, PerQueueThreadHandleInternal::new(unsafe { self.0.as_ref() }.allocator().clone()))
}
#[inline(always)]
pub fn clear<FreeData: Fn(NonNull<T>)>(&mut self, free_data: FreeData)
{
let mut queue_internal = self.0;
unsafe { queue_internal.as_mut() }.clear(&free_data)
}
}