pub struct LocalQueue { /* private fields */ }Expand description
Local queue for thread-per-core scheduler thread-per-core调度器的本地队列
Uses a bounded ring buffer optimized for single consumer (the scheduler thread) with support for external producers (work stealing injectors). Uses interior mutability for thread-safe operations.
使用为单个消费者(调度器线程)优化的有界环形缓冲区, 支持外部生产者(工作窃取注入器)。 使用内部可变性实现线程安全操作。
Implementations§
Source§impl LocalQueue
impl LocalQueue
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new local queue with the specified capacity 创建具有指定容量的新本地队列
The capacity will be rounded up to the next power of 2. 容量将向上舍入到下一个2的幂。
Sourcepub fn push(&self, task: RawTask) -> bool
pub fn push(&self, task: RawTask) -> bool
Push a task to the back of the queue 将任务推入队列后部
Returns true if successful, false if the queue is full.
成功返回 true,队列已满返回 false。
Sourcepub fn pop(&self) -> Option<RawTask>
pub fn pop(&self) -> Option<RawTask>
Pop a task from the front of the queue 从队列前部弹出一个任务
Returns Some(task) if available, None if the queue is empty.
有可用任务时返回 Some(task),队列为空时返回 None。
Sourcepub fn steal(&self, dest: &LocalQueue) -> usize
pub fn steal(&self, dest: &LocalQueue) -> usize
Steal half of the tasks from this queue 从此队列窃取一半任务
Used for work stealing between scheduler threads. 用于调度器线程间的工作窃取。
Returns the number of tasks stolen. 返回被窃取的任务数量。