pub struct Executor { /* private fields */ }Expand description
Top-level executor. One per process is the typical case.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn builder() -> ExecutorBuilder
pub fn builder() -> ExecutorBuilder
Start a new builder.
Sourcepub fn channel<T: Payload>(
&mut self,
name: &str,
) -> Result<Arc<Channel<T>>, ExecutorError>
pub fn channel<T: Payload>( &mut self, name: &str, ) -> Result<Arc<Channel<T>>, ExecutorError>
Open or create a pub/sub channel bound to this executor’s node.
Sourcepub fn service<Req, Resp>(
&mut self,
name: &str,
) -> Result<Arc<Service<Req, Resp>>, ExecutorError>
pub fn service<Req, Resp>( &mut self, name: &str, ) -> Result<Arc<Service<Req, Resp>>, ExecutorError>
Open or create a request/response service bound to this executor’s node.
Sourcepub fn add(
&mut self,
item: impl ExecutableItem,
) -> Result<TaskId, ExecutorError>
pub fn add( &mut self, item: impl ExecutableItem, ) -> Result<TaskId, ExecutorError>
Add an item to the executor with an auto-generated id.
Sourcepub fn add_with_id(
&mut self,
id: impl Into<TaskId>,
item: impl ExecutableItem,
) -> Result<TaskId, ExecutorError>
pub fn add_with_id( &mut self, id: impl Into<TaskId>, item: impl ExecutableItem, ) -> Result<TaskId, ExecutorError>
Add an item with a user-supplied id.
The item’s ExecutableItem::task_id override takes precedence over
the caller-supplied id, which itself takes precedence over the
auto-generated id assigned by Executor::add.
Sourcepub fn add_with_fault_handler<I, H>(
&mut self,
main: I,
handler: H,
) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
H: ExecutableItem,
pub fn add_with_fault_handler<I, H>(
&mut self,
main: I,
handler: H,
) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
H: ExecutableItem,
Register an item plus a fault-handler item.
The main item is registered through the canonical add
path. The handler’s declare_triggers
is called (so handlers that internally rely on the declarer being
invoked observe the call) but its returned trigger list is
ignored — the handler dispatches on the main item’s triggers
while the task is in Faulted state and runs in place of the main
item’s execute(). The pre-built handler dispatch closure is
stashed on the same task entry as the main item’s job,
satisfying REQ_0072.
§Errors
Propagates any error from registering the main item via add, or
from the handler’s declare_triggers call.
§Panics
Panics if the task entry just inserted by add cannot
be located in self.tasks — this is unreachable by construction
and indicates a logic bug.
Sourcepub fn clear_task_fault(
&self,
task: TaskId,
) -> Result<FaultState, ExecutorError>
pub fn clear_task_fault( &self, task: TaskId, ) -> Result<FaultState, ExecutorError>
Clear a per-task fault. Returns the previous FaultState.
Fires Observer::on_task_clear if the state changed from
Faulted to Running. REQ_0070.
§Errors
ExecutorError::TaskNotFoundiftaskis unknown.ExecutorError::TaskNotFaultediftaskis alreadyRunning.
Sourcepub fn clear_executor_fault(&self) -> Result<ExecutorFaultState, ExecutorError>
pub fn clear_executor_fault(&self) -> Result<ExecutorFaultState, ExecutorError>
Clear the executor-wide fault and cascade-clear every task whose
state is Faulted{ExecutorFaulted}. Tasks whose state is
Faulted{BudgetExceeded} are NOT cleared (their own contract
breach is independent). Fires Observer::on_executor_clear and
one Observer::on_task_clear per cascade-cleared task.
REQ_0071.
§Errors
ExecutorError::ExecutorNotFaultedif the executor isRunning.
Sourcepub fn overrun_count(&self, task: TaskId) -> Result<u64, ExecutorError>
pub fn overrun_count(&self, task: TaskId) -> Result<u64, ExecutorError>
Return the per-task overrun counter — number of times the task’s
execute() exceeded its budget over the executor’s lifetime.
Monotonic; not reset by clear_task_fault. REQ_0102.
§Errors
ExecutorError::TaskNotFoundiftaskis unknown.
Sourcepub fn task_fault_state(
&self,
task: TaskId,
) -> Result<FaultState, ExecutorError>
pub fn task_fault_state( &self, task: TaskId, ) -> Result<FaultState, ExecutorError>
Return a snapshot of the per-task FaultState. REQ_0073 (pull path).
§Errors
ExecutorError::TaskNotFoundiftaskis unknown.
Sourcepub fn executor_fault_state(&self) -> ExecutorFaultState
pub fn executor_fault_state(&self) -> ExecutorFaultState
Return a snapshot of the executor-wide ExecutorFaultState.
REQ_0073 (pull path).
Sourcepub fn add_chain<I, C>(&mut self, items: C) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
C: IntoIterator<Item = I>,
pub fn add_chain<I, C>(&mut self, items: C) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
C: IntoIterator<Item = I>,
Add a sequential chain of items. Only the head item’s
declare_triggers is consulted; non-head triggers are ignored with a
tracing warn.
Sourcepub fn add_chain_with_id<I, C>(
&mut self,
id: impl Into<TaskId>,
items: C,
) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
C: IntoIterator<Item = I>,
pub fn add_chain_with_id<I, C>(
&mut self,
id: impl Into<TaskId>,
items: C,
) -> Result<TaskId, ExecutorError>where
I: ExecutableItem,
C: IntoIterator<Item = I>,
Like Executor::add_chain but with a user-supplied id.
Sourcepub fn stoppable(&self) -> Stoppable
pub fn stoppable(&self) -> Stoppable
Returns a Stoppable handle that is waker-aware from the moment the
executor is built. Clone before calling run() — any clone taken at any
time will wake the WaitSet when stop() is called.
Sourcepub const fn iceoryx_node(&self) -> &Node<Service>
pub const fn iceoryx_node(&self) -> &Node<Service>
Borrow the underlying iceoryx2 node (escape hatch for power users).
Sourcepub fn add_graph(&mut self) -> ExecutorGraphBuilder<'_>
pub fn add_graph(&mut self) -> ExecutorGraphBuilder<'_>
Begin building a graph. Call .build() on the returned builder to
register the graph as a task.
Source§impl Executor
impl Executor
Sourcepub fn run(&mut self) -> Result<(), ExecutorError>
pub fn run(&mut self) -> Result<(), ExecutorError>
Run the executor until Stoppable::stop is called or a task signals
stop via crate::Context::stop_executor.
§Errors
Returns the first ExecutorError surfaced during dispatch:
ExecutorError::Itemif any item returnsError panics.ExecutorError::Iceoryx2if aWaitSetoperation fails.ExecutorError::AlreadyRunningif the executor is already running.
If multiple items error in the same dispatch iteration, only the first
is preserved; subsequent errors are discarded silently. To observe
every error, attach an Observer and read errors
via Observer::on_app_error.
Sourcepub fn run_for(&mut self, max: Duration) -> Result<(), ExecutorError>
pub fn run_for(&mut self, max: Duration) -> Result<(), ExecutorError>
Run for at most max wall-clock duration, then return.
§Errors
Returns the first ExecutorError surfaced during dispatch:
ExecutorError::Itemif any item returnsError panics.ExecutorError::Iceoryx2if aWaitSetoperation fails.ExecutorError::AlreadyRunningif the executor is already running.
If multiple items error in the same dispatch iteration, only the first
is preserved; subsequent errors are discarded silently. To observe
every error, attach an Observer and read errors
via Observer::on_app_error.
Sourcepub fn run_n(&mut self, n: usize) -> Result<(), ExecutorError>
pub fn run_n(&mut self, n: usize) -> Result<(), ExecutorError>
Run until n full barrier-cycles (WaitSet wakeups) have completed.
§Errors
Returns the first ExecutorError surfaced during dispatch:
ExecutorError::Itemif any item returnsError panics.ExecutorError::Iceoryx2if aWaitSetoperation fails.ExecutorError::AlreadyRunningif the executor is already running.
If multiple items error in the same dispatch iteration, only the first
is preserved; subsequent errors are discarded silently. To observe
every error, attach an Observer and read errors
via Observer::on_app_error.
Sourcepub fn run_until<F: FnMut() -> bool>(
&mut self,
predicate: F,
) -> Result<(), ExecutorError>
pub fn run_until<F: FnMut() -> bool>( &mut self, predicate: F, ) -> Result<(), ExecutorError>
Run until predicate() returns true. Checked after each WaitSet
wakeup.
§Errors
Returns the first ExecutorError surfaced during dispatch:
ExecutorError::Itemif any item returnsError panics.ExecutorError::Iceoryx2if aWaitSetoperation fails.ExecutorError::AlreadyRunningif the executor is already running.
If multiple items error in the same dispatch iteration, only the first
is preserved; subsequent errors are discarded silently. To observe
every error, attach an Observer and read errors
via Observer::on_app_error.