Task

Struct Task 

Source
pub struct Task { /* private fields */ }

Implementations§

Source§

impl Task

Source

pub fn global_id(&self) -> u32

Source

pub fn leaf_idx(&self) -> u16

Source

pub fn signal_idx(&self) -> u8

Source

pub fn signal_bit(&self) -> u8

Source

pub fn stats(&self) -> TaskStats

Source

pub fn set_cpu_time_tracking(&self, enabled: bool)

Source

pub fn slot(&self) -> Option<NonNull<TaskSlot>>

Source

pub fn clear_slot(&self)

Source

pub fn state(&self) -> &AtomicU8

Source

pub fn schedule(&self)

Attempts to schedule this queue for execution (IDLE -> SCHEDULED transition).

Called by producers after enqueuing items to notify the executor. Uses atomic operations to ensure only one successful schedule per work batch.

§Algorithm
  1. Fast check: If already SCHEDULED, return false immediately (idempotent)
  2. Atomic set: fetch_or(SCHEDULED) to set the SCHEDULED flag
  3. State check: If previous state was IDLE (neither SCHEDULED nor EXECUTING):
    • Set bit in signal word via signal.set(bit_index)
    • If signal transitioned from empty, update summary via waker.mark_active()
    • Return true (successful schedule)
  4. Otherwise: Return false (already scheduled or executing)
§Returns
  • true: Successfully transitioned from IDLE to SCHEDULED (work will be processed)
  • false: Already scheduled/executing, or concurrent schedule won (idempotent)
§Concurrent Behavior
  • Multiple producers: Only the first schedule() succeeds (returns true)
  • During EXECUTING: Sets SCHEDULED flag, which finish() will detect and reschedule
§Memory Ordering
  • Initial load: Acquire (see latest state)
  • fetch_or: Release (publish enqueued items to executor)
§Performance
  • Already scheduled: ~2-3 ns (fast path, single atomic load)
  • Successful schedule: ~10-20 ns (fetch_or + signal update + potential summary update)
§Example
// Producer 1
queue.try_push(item)?;
if gate.schedule() {
    println!("Successfully scheduled");  // First producer
}

// Producer 2 (concurrent)
queue.try_push(another_item)?;
if !gate.schedule() {
    println!("Already scheduled");  // Idempotent, no action needed
}
Source

pub fn is_yielded(&self) -> bool

Source

pub unsafe fn waker_yield(&self) -> Waker

Source

pub unsafe fn poll_future(&self, cx: &mut Context<'_>) -> Option<Poll<()>>

Source

pub fn attach_future(&self, future_ptr: *mut ()) -> Result<(), *mut ()>

Source

pub fn take_future(&self) -> Option<*mut ()>

Source

pub unsafe fn reset( &mut self, global_id: u32, leaf_idx: u16, signal_idx: u8, signal_bit: u8, signal_ptr: *const TaskSignal, slot_ptr: *mut TaskSlot, )

Source

pub fn has_pinned_generator(&self) -> bool

Check if this task has a pinned generator

Source

pub unsafe fn get_pinned_generator<'a>( &self, ) -> Option<&'a mut Box<dyn Iterator<Item = usize> + 'static>>

Get the pinned generator for this task (if any) Safety: Only call from the worker thread that owns this task

Source

pub unsafe fn pin_generator( &self, generator_box: Box<dyn Iterator<Item = usize> + 'static>, mode: GeneratorRunMode, )

Pin a generator to this task Safety: Only call from the worker thread that owns this task

Source

pub fn generator_run_mode(&self) -> GeneratorRunMode

Get the generator run mode

Source

pub unsafe fn set_generator_run_mode(&self, mode: GeneratorRunMode)

Set the generator run mode Safety: Only call from the worker thread that owns this task

Source

pub unsafe fn take_pinned_generator( &self, ) -> Option<Box<Box<dyn Iterator<Item = usize> + 'static>>>

Take ownership of the pinned generator (for cleanup) Safety: Only call from the worker thread that owns this task

Trait Implementations§

Auto Trait Implementations§

§

impl !Freeze for Task

§

impl !RefUnwindSafe for Task

§

impl Unpin for Task

§

impl UnwindSafe for Task

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V