pub struct Executor { /* private fields */ }Expand description
Task executor for synchronous task processing.
Provides a simple run-to-completion model where tasks are executed one at a time. Panics are caught to prevent runtime crashes.
Implementations§
Source§impl Executor
impl Executor
Sourcepub const fn new(work_queue: Arc<WorkQueue>) -> Self
pub const fn new(work_queue: Arc<WorkQueue>) -> Self
Create a new executor with a shared work queue.
Sourcepub fn with_batch_size(self, size: usize) -> Self
pub fn with_batch_size(self, size: usize) -> Self
Set the batch size for processing.
The batch size limits how many tasks are processed per tick() call.
Sourcepub fn tick(&mut self) -> usize
pub fn tick(&mut self) -> usize
Process one tick (up to batch_size tasks).
Returns the total number of tasks processed (successful + failed).
Sourcepub fn execute_task(task: &mut Task) -> bool
pub fn execute_task(task: &mut Task) -> bool
Execute a single task with panic handling.
Returns true if the task completed successfully, false if it
failed or panicked.
Sourcepub fn schedule(&self, task: Task) -> bool
pub fn schedule(&self, task: Task) -> bool
Schedule a task for execution.
Returns false if the queue is full.
Sourcepub fn spawn<F>(&self, work: F) -> bool
pub fn spawn<F>(&self, work: F) -> bool
Schedule work using a closure.
Convenience method that creates a task with normal priority.
Sourcepub const fn executed_count(&self) -> u64
pub const fn executed_count(&self) -> u64
Get the total number of successfully executed tasks.
Sourcepub const fn failed_count(&self) -> u64
pub const fn failed_count(&self) -> u64
Get the total number of failed tasks.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if there’s pending work.
Sourcepub const fn batch_size(&self) -> usize
pub const fn batch_size(&self) -> usize
Get the current batch size.
Sourcepub fn drain(&mut self) -> usize
pub fn drain(&mut self) -> usize
Drain all pending tasks, executing each one.
Returns the total number of tasks processed.
Sourcepub const fn reset_stats(&mut self)
pub const fn reset_stats(&mut self)
Reset execution statistics.