Skip to main content

Module scheduler

Module scheduler 

Source
Expand description

Per-core task queues: LocalQueue (ring buffer) + GlobalQueue (mutex deque).

ยงDesign

  • LocalQueue โ€” fixed-capacity 256-slot ring buffer for LIFO local dequeuing. Overflow tasks (when ring is full) are spilled to the GlobalQueue.
  • GlobalQueue โ€” Mutex<VecDeque<Arc<TaskHeader>>> for cross-thread injection and work-stealing. Also stores Task handles for executor ownership.

Both queues operate on Arc<TaskHeader> for the waker path, and Task for the executor-ownership path. The distinction matters for drop semantics:

  • Wakers push Arc<TaskHeader> (no Future ownership).
  • Executor pops Arc<TaskHeader> and looks up its owned Task by pointer.

For simplicity in the single-threaded executor, both queues store Arc<TaskHeader> and the executor maintains a separate slab of Task owners.