Struct InterruptibleSleepInterface

Inheritance Relationships

Derived Types

Struct Documentation

struct InterruptibleSleepInterface

Interface to an object whose sleep() calls can be interrupted externally. Multiple sleep() calls can be happening at a time. The object waits for the last sleep() call to finish on destruction. No more sleep() calls can be made once destruction of the object started (sleep() will return false in such case). Make sure that ok() returns false when this object is about to be destroyed.

Subclassed by cras::InterruptibleTFBuffer, cras::StatefulNodeletInterface

Public Functions

InterruptibleSleepInterface()
virtual ~InterruptibleSleepInterface()

Destroy the object waiting for a pending sleep() call to finish.

virtual bool sleep(const ::ros::Duration &duration) const

Sleep for the given duration or until ok() returns false.

Parameters:

duration[in] The duration to sleep for.

Returns:

Whether the requested duration has elapsed.

virtual bool ok() const

Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible.

Note

Always override this function as its default implementation returns false (used in case this function is called after the descendant parts of the objects have already been destructed).

Returns:

Whether it is OK to continue.

Protected Attributes

::ros::WallDuration pollDuration = {0, 1000000}

How long to wait between querying the ok() status and other conditions.