Public Member Functions | Protected Attributes | Private Attributes | List of all members
cras::InterruptibleSleepInterface Struct Reference

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

#include <interruptible_sleep_interface.h>

Inheritance diagram for cras::InterruptibleSleepInterface:
Inheritance graph
[legend]

Public Member Functions

 InterruptibleSleepInterface ()
 
virtual bool ok () const
 Whether it is OK to continue sleeping. If false, a pending sleep() should stop as soon as possible. More...
 
virtual bool sleep (const ::ros::Duration &duration) const
 Sleep for the given duration or until ok() returns false. More...
 
virtual ~InterruptibleSleepInterface ()
 Destroy the object waiting for a pending sleep() call to finish. More...
 

Protected Attributes

::ros::WallDuration pollDuration {0, 1000000}
 How long to wait between querying the ok() status and other conditions. More...
 

Private Attributes

::std::unique_ptr< InterruptibleSleepInterfacePrivate > data
 PIMPL data container. More...
 

Detailed Description

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.

Definition at line 26 of file interruptible_sleep_interface.h.

Constructor & Destructor Documentation

◆ InterruptibleSleepInterface()

cras::InterruptibleSleepInterface::InterruptibleSleepInterface ( )

◆ ~InterruptibleSleepInterface()

virtual cras::InterruptibleSleepInterface::~InterruptibleSleepInterface ( )
virtual

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

Member Function Documentation

◆ ok()

virtual bool cras::InterruptibleSleepInterface::ok ( ) const
virtual

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

Returns
Whether it is OK to continue.
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).

Reimplemented in cras::InterruptibleTFBuffer, cras::StatefulNodelet< NodeletType >, and cras::NodeletAwareTFBuffer.

◆ sleep()

virtual bool cras::InterruptibleSleepInterface::sleep ( const ::ros::Duration duration) const
virtual

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

Parameters
[in]durationThe duration to sleep for.
Returns
Whether the requested duration has elapsed.

Member Data Documentation

◆ data

::std::unique_ptr<InterruptibleSleepInterfacePrivate> cras::InterruptibleSleepInterface::data
private

PIMPL data container.

Definition at line 57 of file interruptible_sleep_interface.h.

◆ pollDuration

::ros::WallDuration cras::InterruptibleSleepInterface::pollDuration {0, 1000000}
protected

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

Definition at line 53 of file interruptible_sleep_interface.h.


The documentation for this struct was generated from the following file:


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Sun Jan 14 2024 03:48:14