Fawkes API
Fawkes Development Version
|
#include <>>
Public Member Functions | |
TimeWait (Clock *clock, long int desired_loop_time_usec) | |
Constructor. More... | |
~TimeWait () | |
Destructor. More... | |
void | mark_start () |
Mark start of loop. More... | |
void | wait () |
Wait until minimum loop time has been reached. More... | |
void | wait_systime () |
Wait until minimum loop time has been reached in real time. More... | |
Static Public Member Functions | |
static void | wait (long int usec) |
Wait at least usec microseconds. More... | |
static void | wait_systime (long int usec) |
Wait at least usec microseconds. More... | |
Time wait utility.
This class allows for guaranteed waiting for a specified amout of time. It can either be used to suspend the current thread for at least the given time (static methods) or it can be used to reach a desired minimum loop time. For this instantiate the class and call set_start() at the beginning of the loop and wait() at the end. wait() will then suspend the thread as long as needed to have the desired minimum loop time. The TimeWait utility will use the current clock time. Thus it may wait for a given amount of say simulated time.
fawkes::TimeWait::TimeWait | ( | Clock * | clock, |
long int | desired_loop_time_usec | ||
) |
void fawkes::TimeWait::mark_start | ( | ) |
Mark start of loop.
Definition at line 70 of file wait.cpp.
References fawkes::Clock::get_systime(), and fawkes::Clock::get_time().
Referenced by RosClockThread::loop(), HokuyoUrgAcquisitionThread::loop(), RRDThread::loop(), ProcRRDThread::loop(), MongoRRDThread::loop(), WebviewPtzCamThread::loop(), MongoLogTransformsThread::loop(), BlackBoardSynchronizationThread::loop(), MongoLogImagesThread::loop(), MongoLogPointCloudThread::loop(), ColliThread::loop(), fawkes::FawkesMainThread::loop(), OpenRobotinoComThread::loop(), and fawkes::WebviewJpegStreamProducer::loop().
void fawkes::TimeWait::wait | ( | ) |
Wait until minimum loop time has been reached.
Definition at line 81 of file wait.cpp.
References fawkes::Clock::get_time().
Referenced by HokuyoUrgAcquisitionThread::loop(), WebviewPtzCamThread::loop(), MongoLogTransformsThread::loop(), MongoLogImagesThread::loop(), MongoLogPointCloudThread::loop(), ColliThread::loop(), and OpenRobotinoComThread::loop().
|
static |
Wait at least usec microseconds.
Think of this as an uninterruptible usleep(). This method will not return before at least usec microseconds have passed. It may be longer but never less. Time is tracked in the current Clock time scale. This may be simulated time or real time. It is assumed that the (simulated time) is at worst slower, but never faster than real time. Thus 1 microsecond real time is at least 1 microsecond clock time.
usec | number of microseconds to wait at least |
Definition at line 143 of file wait.cpp.
References fawkes::Clock::get_time(), fawkes::Clock::instance(), and fawkes::time_diff_usec().
void fawkes::TimeWait::wait_systime | ( | ) |
Wait until minimum loop time has been reached in real time.
This uses the system time and not an external time source if defined.
Definition at line 100 of file wait.cpp.
References fawkes::Clock::get_systime().
Referenced by RosClockThread::loop(), RRDThread::loop(), ProcRRDThread::loop(), MongoRRDThread::loop(), BlackBoardSynchronizationThread::loop(), fawkes::FawkesMainThread::loop(), and fawkes::WebviewJpegStreamProducer::loop().
|
static |
Wait at least usec microseconds.
Think of this as an uninterruptible usleep(). This method will not return before at least usec microseconds have passed. It may be longer but never less. Time is tracked in system time scale (real time).
usec | number of microseconds to wait at least |
Definition at line 122 of file wait.cpp.
References fawkes::time_diff_usec().