#[derive(Debug)]
pub struct PerQueueThreadHandle<'queue, T: 'queue, A: 'queue + Allocator>(&'queue CcQueue<T, A>, NonNull<PerQueueThreadHandleInternal<T, A>>);
impl<'queue, T, A: Allocator> Drop for PerQueueThreadHandle<'queue, T, A>
{
#[inline(always)]
fn drop(&mut self)
{
let pointer = self.1;
unsafe { drop_in_place(pointer.as_ptr()) }
PerQueueThreadHandleInternal::free_after_drop(pointer);
}
}
impl<'queue, T, A: Allocator> PerQueueThreadHandle<'queue, T, A>
{
#[inline(always)]
pub fn enqueue(&mut self, data: NonNull<T>)
{
let queue = unsafe { (self.0).0.as_ref() };
queue.enqueue(self.handle(), data)
}
#[inline(always)]
pub fn dequeue(&mut self) -> Option<NonNull<T>>
{
let queue = unsafe { (self.0).0.as_ref() };
queue.dequeue(self.handle())
}
#[inline(always)]
fn handle(&mut self) -> &mut PerQueueThreadHandleInternal<T, A>
{
unsafe { (self.1).as_mut() }
}
}