#[derive(Debug)]
#[repr(C)]
struct PerQueueThreadHandleInternal<T, A: Allocator>
{
enq: SynchHandle<T>,
deq: SynchHandle<T>,
next: *mut Node<T>,
allocator: A,
}
impl<T, A: Allocator> Drop for PerQueueThreadHandleInternal<T, A>
{
#[inline(always)]
fn drop(&mut self)
{
if self.next.is_not_null()
{
self.allocator.free_cache_line_size(unsafe { NonNull::new_unchecked(self.next) });
}
}
}
impl<T, A: Allocator> PerQueueThreadHandleInternal<T, A>
{
#[inline(always)]
fn allocate_next_node(&mut self) -> NonNull<Node<T>>
{
Self::allocate_next_node_(&mut self.allocator)
}
#[inline(always)]
fn allocate_next_node_(allocator: &mut A) -> NonNull<Node<T>>
{
allocator.align_malloc_cache_line_size()
}
#[inline(always)]
fn free_after_drop(this: NonNull<Self>)
{
HeapAllocator.free_page_size(this)
}
#[inline(always)]
fn new(mut allocator: A) -> NonNull<Self>
{
let mut handle = HeapAllocator.align_malloc_page_size();
unsafe
{
let handle: &mut Self = handle.as_mut();
handle.enq.ccsynch_handle_init();
handle.deq.ccsynch_handle_init();
write(&mut handle.next, Self::allocate_next_node_(&mut allocator).as_ptr());
write(&mut handle.allocator, allocator);
}
handle
}
}