rclrs

Struct WaitSet

Source
pub struct WaitSet { /* private fields */ }
Expand description

A struct for waiting on subscriptions and other waitable entities to become ready.

Implementations§

Source§

impl WaitSet

Source

pub fn new( number_of_subscriptions: usize, number_of_guard_conditions: usize, number_of_timers: usize, number_of_clients: usize, number_of_services: usize, number_of_events: usize, context: &Context, ) -> Result<Self, RclrsError>

Creates a new wait set.

The given number of subscriptions is a capacity, corresponding to how often WaitSet::add_subscription may be called.

Source

pub fn new_for_node(node: &Node) -> Result<Self, RclrsError>

Creates a new wait set and adds all waitable entities in the node to it.

The wait set is sized to fit the node exactly, so there is no capacity for adding other entities.

Source

pub fn clear(&mut self)

Removes all entities from the wait set.

This effectively resets the wait set to the state it was in after being created by WaitSet::new.

Source

pub fn add_subscription( &mut self, subscription: Arc<dyn SubscriptionBase>, ) -> Result<(), RclrsError>

Adds a subscription to the wait set.

§Errors
  • If the subscription was already added to this wait set or another one, AlreadyAddedToWaitSet will be returned
  • If the number of subscriptions in the wait set is larger than the capacity set in WaitSet::new, WaitSetFull will be returned
Source

pub fn add_guard_condition( &mut self, guard_condition: Arc<GuardCondition>, ) -> Result<(), RclrsError>

Adds a guard condition to the wait set.

§Errors
  • If the guard condition was already added to this wait set or another one, AlreadyAddedToWaitSet will be returned
  • If the number of guard conditions in the wait set is larger than the capacity set in WaitSet::new, WaitSetFull will be returned
Source

pub fn add_client( &mut self, client: Arc<dyn ClientBase>, ) -> Result<(), RclrsError>

Adds a client to the wait set.

§Errors
  • If the client was already added to this wait set or another one, AlreadyAddedToWaitSet will be returned
  • If the number of clients in the wait set is larger than the capacity set in WaitSet::new, WaitSetFull will be returned
Source

pub fn add_service( &mut self, service: Arc<dyn ServiceBase>, ) -> Result<(), RclrsError>

Adds a service to the wait set.

§Errors
  • If the service was already added to this wait set or another one, AlreadyAddedToWaitSet will be returned
  • If the number of services in the wait set is larger than the capacity set in WaitSet::new, WaitSetFull will be returned
Source

pub fn wait( self, timeout: Option<Duration>, ) -> Result<ReadyEntities, RclrsError>

Blocks until the wait set is ready, or until the timeout has been exceeded.

If the timeout is None then this function will block indefinitely until something in the wait set is valid or it is interrupted.

If the timeout is Duration::ZERO then this function will be non-blocking; checking what’s ready now, but not waiting if nothing is ready yet.

If the timeout is greater than Duration::ZERO then this function will return after that period of time has elapsed or the wait set becomes ready, which ever comes first.

This function does not change the entities registered in the wait set.

§Errors
  • Passing a wait set with no wait-able items in it will return an error.
  • The timeout must not be so large so as to overflow an i64 with its nanosecond representation, or an error will occur.

This list is not comprehensive, since further errors may occur in the rmw or rcl layers.

Trait Implementations§

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<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, 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.