pub struct WaitSet { /* private fields */ }
Expand description
A struct for waiting on subscriptions and other waitable entities to become ready.
Implementations§
Source§impl WaitSet
impl WaitSet
Sourcepub 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>
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.
Sourcepub fn new_for_node(node: &Node) -> Result<Self, RclrsError>
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.
Sourcepub fn clear(&mut self)
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
.
Sourcepub fn add_subscription(
&mut self,
subscription: Arc<dyn SubscriptionBase>,
) -> Result<(), RclrsError>
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
Sourcepub fn add_guard_condition(
&mut self,
guard_condition: Arc<GuardCondition>,
) -> Result<(), RclrsError>
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
Sourcepub fn add_client(
&mut self,
client: Arc<dyn ClientBase>,
) -> Result<(), RclrsError>
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
Sourcepub fn add_service(
&mut self,
service: Arc<dyn ServiceBase>,
) -> Result<(), RclrsError>
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
Sourcepub fn wait(
self,
timeout: Option<Duration>,
) -> Result<ReadyEntities, RclrsError>
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.