Skip to main content

Executor

Struct Executor 

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

Implementations§

Source§

impl Executor

Source

pub fn new() -> Self

Single-threaded executor: all callbacks run on the spin/I/O thread.

Source

pub fn with_context(context: Context) -> Self

Executor whose sockets share context (required for inproc with broker/Nodes).

Source

pub fn with_worker_pool(max_workers: usize) -> Self

Offload callbacks to max_workers resident threads (subscriptions, timers, services, and action servers), subject to each callback group.

Source

pub fn with_context_and_worker_pool( context: Context, max_workers: usize, ) -> Self

Like with_worker_pool, sharing context.

Source

pub fn context(&self) -> &Context

Shared runtime context used for ZMQ sockets.

Source

pub fn shutdown_handle(&self) -> ShutdownHandle

Cloneable handle to stop spin / start.

Source

pub fn worker_queue_stats(&self) -> Option<QueueStats>

Waiting callback jobs and rejected submissions for the resident pool. Mutually exclusive groups expose their own additional waiting queues.

Source

pub fn stream_hwm(&self) -> HighWaterMark

Defaults used for newly connected PUB/SUB sockets.

Source

pub fn rpc_hwm(&self) -> HighWaterMark

Defaults used for newly registered service workers.

Source

pub fn action_hwm(&self) -> HighWaterMark

Defaults used for newly connected action sockets.

Source

pub fn set_stream_hwm(&mut self, hwm: HighWaterMark) -> Result<()>

Set HWM applied to subsequent connect_subscriber sockets.

Already-connected SUB sockets are updated in place when present.

Source

pub fn set_rpc_hwm(&mut self, hwm: HighWaterMark) -> Result<()>

Set HWM applied to subsequent register_service sockets.

Source

pub fn set_action_hwm(&mut self, hwm: HighWaterMark) -> Result<()>

Set HWM applied to subsequent action client / worker sockets.

Source

pub fn shutdown(&self)

Signal the executor to leave spin / background start.

Source

pub fn connect_subscriber(&mut self, endpoint: Option<&str>) -> Result<()>

Source

pub fn subscribe( &mut self, topic: &str, callback: MessageCallback, group: CallbackGroup, ) -> Result<SubscriptionHandle>

Source

pub fn destroy_subscription(&mut self, handle: SubscriptionHandle) -> Result<()>

Remove a subscription created by subscribe.

When the last callback for a topic is removed, the SUB socket unsubscribes from that topic filter.

Source

pub fn subscribe_typed<M, F>( &mut self, topic: &str, callback: F, group: CallbackGroup, ) -> Result<SubscriptionHandle>
where M: Message + Default + 'static, F: Fn(M) + Send + Sync + 'static,

Subscribe with a protobuf-typed callback. Decode failures are skipped.

Source

pub fn create_timer( &mut self, period: Duration, callback: TimerCallback, group: CallbackGroup, ) -> Result<TimerHandle>

Create a periodic timer (ROS 2 create_timer).

First fire is after period. Concurrency follows group.

Source

pub fn cancel_timer(&mut self, handle: TimerHandle) -> Result<()>

Cancel a timer created by create_timer.

Source

pub fn connect_action_client(&mut self, endpoint: Option<&str>) -> Result<()>

Source

pub fn send_goal( &self, action_name: &str, body: &[u8], callback: ActionMessageCallback, goal_id: Option<&str>, ) -> Result<String>

Source

pub fn cancel_goal( &self, action_name: &str, goal_id: &str, body: &[u8], ) -> Result<()>

Source

pub fn register_service( &mut self, service_name: &str, handler: ServiceHandler, callback_group: CallbackGroup, backend_endpoint: Option<&str>, identity: Option<&str>, hwm: Option<HighWaterMark>, ) -> Result<u64>

Source

pub fn destroy_service(&mut self, id: u64) -> Result<()>

Disconnect and remove a service worker registered by [register_service].

Source

pub fn register_action( &mut self, action_name: &str, handler: ActionGoalHandler, callback_group: CallbackGroup, backend_endpoint: Option<&str>, identity: Option<&str>, hwm: Option<HighWaterMark>, ) -> Result<u64>

Source

pub fn register_action_live( &mut self, action_name: &str, handler: ActionGoalLiveHandler, callback_group: CallbackGroup, backend_endpoint: Option<&str>, identity: Option<&str>, hwm: Option<HighWaterMark>, ) -> Result<u64>

Register a live action worker that can publish FEEDBACK before returning RESULT.

Source

pub fn destroy_action_server(&mut self, id: u64) -> Result<()>

Disconnect and remove an action worker registered by [register_action].

Source

pub fn spin_once(&mut self, timeout: Option<Duration>) -> Result<bool>

One executor step (ROS 2 spin_once): wait up to timeout, then dispatch every currently readable registration and due timers.

Returns true if at least one socket was readable or a timer fired.

Source

pub fn spin_some(&mut self, timeout: Option<Duration>) -> Result<()>

Wait up to timeout for work, then drain ready callbacks (ROS 2 spin_some).

After the first successful poll / timer fire, further iterations use a zero timeout so only already-queued messages are processed before returning.

Source

pub fn spin(&mut self) -> Result<()>

Block on the executor until shutdown (ROS 2 spin).

Source

pub fn start(&mut self) -> Result<()>

Run the executor on a background thread until shutdown or stop.

Source

pub fn stop(&mut self)

Source

pub fn wait(&mut self)

Trait Implementations§

Source§

impl Default for Executor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Executor

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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