Class WaitSet

Class Documentation

class WaitSet

Wait set.

Waits on a set of subscriptions, clients, and servers. TODO(christophebedard) allow waiting for ALL conditions

Public Functions

WaitSet()

Constructor.

~WaitSet()
bool wait(const std::chrono::milliseconds timeout = std::chrono::milliseconds(-1))

Wait.

Wait on the wait set.

A negative timeout value means to wait indefinitely. A timeout value equal to 0 means to do a non-blocking check and not wait. A positive timeout value will be used as a timeout.

This will wait until at least one object (subscription, client, or server) is ready, or until the timeout has been reached. The objects that are ready will have their respective pointers be non-nullptr in their respective vectors; the rest will have their pointers set to nullptr.

Waiting on an empty waitset with a timeout>=0 is similar to a sleep() call.

Parameters:

timeout – the timeout

Returns:

whether the wait call timed out

void add_subscription(Subscription *subscription)

Add a subscription.

Must not be nullptr.

void add_client(ServiceClient *client)

Add a client.

Must not be nullptr.

void add_server(ServiceServer *server)

Add a server.

Must not be nullptr.

void add_guard_condition(GuardCondition *guard_condition)

Add a guard condition.

Must not be nullptr.

const std::vector<Subscription*> &get_subscriptions() const

Get the subscriptions.

const std::vector<ServiceClient*> &get_clients() const

Get the clients.

const std::vector<ServiceServer*> &get_servers() const

Get the servers.

const std::vector<GuardCondition*> &get_guard_conditions() const

Get the guard conditions.

void clear()

Clear the wait set content.

This must be called after calling wait() and checking the result.