#[allow(unused_variables)]
fn queue_new_inner<const ALLOW_UNBOUND: bool>(owner: &TaskThread) -> TaskQueue<ALLOW_UNBOUND> {
TaskQueue::<ALLOW_UNBOUND> { owner: owner.id(), entries: LinkedList::new(QueueAdapter { links: LinkOps, pointers: DefaultPointerOps::new() }), count: 0, closed: false, local: PhantomData }
}
#[allow(unused_variables)]
fn queue_owner_inner<const ALLOW_UNBOUND: bool>(this: &TaskQueue<ALLOW_UNBOUND>) -> TaskOwnerId {
this.owner
}
#[allow(unused_variables)]
fn queue_len_inner<const ALLOW_UNBOUND: bool>(this: &TaskQueue<ALLOW_UNBOUND>) -> usize {
this.count
}
#[allow(unused_variables)]
fn queue_is_empty_inner<const ALLOW_UNBOUND: bool>(this: &TaskQueue<ALLOW_UNBOUND>) -> bool {
this.count == 0
}
fn queue_new_with_unbound_inner(owner: &TaskThread) -> TaskQueue<true> {
TaskQueue {
owner: owner.id(),
entries: LinkedList::new(QueueAdapter { links: LinkOps, pointers: DefaultPointerOps::new() }),
count: 0,
closed: false,
local: PhantomData,
}
}
fn queue_push_count_inner<const ALLOW_UNBOUND: bool, const FRONT: bool>(
queue: &TaskQueue<ALLOW_UNBOUND>,
task: &Runnable,
) -> std::result::Result<usize, QueuePushErrorKind> {
match task.snapshot().owner {
Some(owner) if owner == queue.owner => {}
None if ALLOW_UNBOUND && !FRONT => {}
_ => return Err(QueuePushErrorKind::WrongOwner),
}
queue.count.checked_add(1).ok_or(QueuePushErrorKind::CountOverflow)
}
fn queue_append_count_inner<const ALLOW_UNBOUND: bool>(
queue: &TaskQueue<ALLOW_UNBOUND>,
batch: &TaskBatch,
) -> std::result::Result<usize, QueuePushErrorKind> {
let count = queue.count.checked_add(batch.tasks.len()).ok_or(QueuePushErrorKind::CountOverflow)?;
if batch.tasks.iter().any(|task| task.snapshot().owner != Some(queue.owner)) {
return Err(QueuePushErrorKind::WrongOwner);
}
Ok(count)
}
unsafe fn queue_link_inner<const ALLOW_UNBOUND: bool, const FRONT: bool>(
queue: &mut TaskQueue<ALLOW_UNBOUND>,
node: NonNull<QueueEntry>,
) {
let value = unsafe { UnsafeRef::from_raw(node.as_ptr()) };
if FRONT {
queue.entries.push_front(value);
} else {
queue.entries.push_back(value);
}
}
fn queue_unlink_inner<const ALLOW_UNBOUND: bool, const FRONT: bool>(
queue: &mut TaskQueue<ALLOW_UNBOUND>,
) -> Option<NonNull<QueueEntry>> {
let node = if FRONT { queue.entries.pop_front() } else { queue.entries.pop_back() }?;
queue.count = queue.count.checked_sub(1).unwrap_or_else(|| std::process::abort());
Some(NonNull::from(&*node))
}
#[allow(unused_variables)]
unsafe fn adapter_value_inner(
this: &QueueAdapter,
link: NonNull<LinkedListLink>,
) -> *const QueueEntry {
unsafe { QueueEntry::node_from_link(link) }.as_ptr()
}
#[allow(unused_variables)]
unsafe fn adapter_link_inner(
this: &QueueAdapter,
value: *const QueueEntry,
) -> NonNull<LinkedListLink> {
unsafe { QueueEntry::link_from_node(NonNull::new(value.cast_mut()).unwrap_or_else(|| std::process::abort())) }
}
#[allow(unused_variables)]
fn adapter_ops_inner(this: &QueueAdapter) -> &LinkOps {
&this.links
}
#[allow(unused_variables)]
fn adapter_ops_mut_inner(this: &mut QueueAdapter) -> &mut LinkOps {
&mut this.links
}
#[allow(unused_variables)]
fn adapter_pointer_ops_inner(this: &QueueAdapter) -> &DefaultPointerOps<UnsafeRef<QueueEntry>> {
&this.pointers
}