WorkerService

Struct WorkerService 

Source
pub struct WorkerService<const P: usize = DEFAULT_QUEUE_SEG_SHIFT, const NUM_SEGS_P2: usize = DEFAULT_QUEUE_NUM_SEGS_SHIFT> { /* private fields */ }

Implementations§

Source§

impl<const P: usize, const NUM_SEGS_P2: usize> WorkerService<P, NUM_SEGS_P2>

Source

pub fn start( arena: TaskArena, config: WorkerServiceConfig, tick_service: &Arc<TickService>, ) -> Arc<Self>

Source

pub fn arena(&self) -> &TaskArena

Get a reference to the ExecutorArena owned by this service.

Source

pub fn summary(&self) -> &Summary

Get a reference to the SummaryTree owned by this service.

Source

pub fn reserve_task(&self) -> Option<TaskHandle>

Reserve a task slot using the SummaryTree.

Source

pub fn release_task(&self, handle: TaskHandle)

Release a task slot back to the SummaryTree.

Source

pub fn spawn_worker(&self) -> Result<(), PushError<()>>
where Self: Sized,

Source

pub fn tick_duration(&self) -> Duration

Source

pub fn clock_ns(&self) -> u64

Source

pub fn shutdown(&self)

Source

pub fn worker_count(&self) -> usize

Returns the current worker count

Source

pub fn worker_has_work(&self, worker_id: usize) -> bool

Checks if a specific worker has any work to do

Source

pub fn interrupt_worker( &self, worker_id: usize, ) -> Result<bool, PreemptionError>

Interrupt a specific worker thread to trigger preemptive generator switching.

The worker thread is NOT terminated! It is only briefly interrupted to:

  1. Pin its current generator to the running task (save stack state)
  2. Create a new generator for itself
  3. Continue executing with the new generator

The interrupted task can later be resumed with its pinned generator. This allows true preemptive multitasking at the task level.

Can be called from any thread (e.g., a timer thread).

§Arguments
  • worker_id - The ID of the worker to interrupt (0-based index)
§Returns
  • Ok(true) - Worker was successfully interrupted
  • Ok(false) - Worker doesn’t exist (invalid ID)
  • Err - Interrupt operation failed (platform error)

Trait Implementations§

Source§

impl<const P: usize, const NUM_SEGS_P2: usize> Drop for WorkerService<P, NUM_SEGS_P2>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<const P: usize, const NUM_SEGS_P2: usize> TickHandler for WorkerService<P, NUM_SEGS_P2>

Source§

fn tick_duration(&self) -> Duration

Returns the desired tick duration for this handler. The TickService will use the minimum of all registered handlers’ tick durations.
Source§

fn on_tick(&self, tick_count: u64, now_ns: u64)

Called on each tick with the current time in nanoseconds and tick count.
Source§

fn on_shutdown(&self)

Called when the tick service is shutting down.
Source§

impl<const P: usize, const NUM_SEGS_P2: usize> Send for WorkerService<P, NUM_SEGS_P2>

Source§

impl<const P: usize, const NUM_SEGS_P2: usize> Sync for WorkerService<P, NUM_SEGS_P2>

Auto Trait Implementations§

§

impl<const P: usize = DEFAULT_QUEUE_SEG_SHIFT, const NUM_SEGS_P2: usize = DEFAULT_QUEUE_NUM_SEGS_SHIFT> !Freeze for WorkerService<P, NUM_SEGS_P2>

§

impl<const P: usize = DEFAULT_QUEUE_SEG_SHIFT, const NUM_SEGS_P2: usize = DEFAULT_QUEUE_NUM_SEGS_SHIFT> !RefUnwindSafe for WorkerService<P, NUM_SEGS_P2>

§

impl<const P: usize, const NUM_SEGS_P2: usize> Unpin for WorkerService<P, NUM_SEGS_P2>

§

impl<const P: usize = DEFAULT_QUEUE_SEG_SHIFT, const NUM_SEGS_P2: usize = DEFAULT_QUEUE_NUM_SEGS_SHIFT> !UnwindSafe for WorkerService<P, NUM_SEGS_P2>

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