|
blocxx
|
A TimeoutTimer is used by an algorithm to determine when a timeout has expired. More...
#include <TimeoutTimer.hpp>
Public Member Functions | |
| TimeoutTimer (const Timeout &x) | |
| virtual | ~TimeoutTimer () |
| void | start () |
| Meant to be called by timeout functions which loop. More... | |
| void | resetOnLoop () |
| Meant to be called by timeout functions which loop, and that want to reset the interval. More... | |
| void | loop () |
| Meant to be called by timeout functions which loop, but don't want to reset the interval. More... | |
| bool | expired () const |
| Indicates whether the last loop time has exceeded the timeout. More... | |
| bool | infinite () const |
| Indicates whether the timeout will never expire. More... | |
| Timeout | asTimeout () const |
| Timeout | asRelativeTimeout () const |
| Timeout | asRelativeTimeout (double maxSeconds) const |
| Timeout | asAbsoluteTimeout () const |
| Converts the timer to an absolute timeout. More... | |
| int | asIntMs () const |
| int | asIntMs (double maxSeconds) const |
Private Member Functions | |
| double | calcSeconds () const |
| double | calcSeconds (double maxSeconds) const |
| virtual DateTime | getCurrentTime () const |
Private Attributes | |
| Timeout | m_timeout |
| DateTime | m_start |
| DateTime | m_loopTime |
A TimeoutTimer is used by an algorithm to determine when a timeout has expired.
It is used like this:
TimeoutTimer timer(theTimeout); while (... && !timer.expired()) { // wait for something to happen, maybe calling select() or something else. struct timeval tv; select(... , timer.asTimeval(tv));
... // processing
if (something happened that might reset the interval) timer.resetOnLoop(); else timer.loop(); }
Definition at line 105 of file TimeoutTimer.hpp.
| BLOCXX_NAMESPACE::TimeoutTimer::TimeoutTimer | ( | const Timeout & | x | ) |
Definition at line 78 of file TimeoutTimer.cpp.
|
virtual |
Definition at line 85 of file TimeoutTimer.cpp.
| Timeout BLOCXX_NAMESPACE::TimeoutTimer::asAbsoluteTimeout | ( | ) | const |
Converts the timer to an absolute timeout.
If the timer is infinite, the return will be an infinite relative timeout
Definition at line 283 of file TimeoutTimer.cpp.
References calcSeconds(), and infinite().
Referenced by BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::acquireWriteLock(), and BLOCXX_NAMESPACE::GenericRWLockImpl< IdT, CompareT >::GenericRWLockImpl().
| int BLOCXX_NAMESPACE::TimeoutTimer::asIntMs | ( | ) | const |
Definition at line 330 of file TimeoutTimer.cpp.
References BLOCXX_NAMESPACE::DateTime::get(), BLOCXX_NAMESPACE::Timeout::getAbsolute(), BLOCXX_NAMESPACE::DateTime::getMicrosecond(), m_loopTime, and m_timeout.
| int BLOCXX_NAMESPACE::TimeoutTimer::asIntMs | ( | double | maxSeconds | ) | const |
Definition at line 343 of file TimeoutTimer.cpp.
| Timeout BLOCXX_NAMESPACE::TimeoutTimer::asRelativeTimeout | ( | ) | const |
Definition at line 271 of file TimeoutTimer.cpp.
Referenced by BLOCXX_NAMESPACE::Exec::processInputOutput().
| Timeout BLOCXX_NAMESPACE::TimeoutTimer::asRelativeTimeout | ( | double | maxSeconds | ) | const |
Definition at line 277 of file TimeoutTimer.cpp.
| Timeout BLOCXX_NAMESPACE::TimeoutTimer::asTimeout | ( | ) | const |
Definition at line 237 of file TimeoutTimer.cpp.
|
private |
Definition at line 243 of file TimeoutTimer.cpp.
Referenced by asAbsoluteTimeout().
|
private |
Definition at line 263 of file TimeoutTimer.cpp.
| bool BLOCXX_NAMESPACE::TimeoutTimer::expired | ( | ) | const |
Indicates whether the last loop time has exceeded the timeout.
The current time is not used, but the time when resetOnLoop() or loop() was called.
Definition at line 143 of file TimeoutTimer.cpp.
Referenced by BLOCXX_NAMESPACE::Exec::processInputOutput().
|
privatevirtual |
Definition at line 397 of file TimeoutTimer.cpp.
| bool BLOCXX_NAMESPACE::TimeoutTimer::infinite | ( | ) | const |
Indicates whether the timeout will never expire.
Definition at line 163 of file TimeoutTimer.cpp.
Referenced by asAbsoluteTimeout().
| void BLOCXX_NAMESPACE::TimeoutTimer::loop | ( | ) |
Meant to be called by timeout functions which loop, but don't want to reset the interval.
It should be called each time through the loop. Either resetOnLoop() or loop() should be called each time through the loop, but not both.
Definition at line 106 of file TimeoutTimer.cpp.
Referenced by BLOCXX_NAMESPACE::Exec::processInputOutput().
| void BLOCXX_NAMESPACE::TimeoutTimer::resetOnLoop | ( | ) |
Meant to be called by timeout functions which loop, and that want to reset the interval.
It should be called each time through the loop. For a relative with reset timeout it will reset the interval. Either resetOnLoop() or loop() should be called each time through the loop, but not both.
Definition at line 96 of file TimeoutTimer.cpp.
Referenced by BLOCXX_NAMESPACE::Exec::processInputOutput().
| void BLOCXX_NAMESPACE::TimeoutTimer::start | ( | ) |
Meant to be called by timeout functions which loop.
Normally, it should be called once, at the beginning of the function. The time this is called marks the beginning of a relative interval. For an absolute timeout, it does nothing. It is not necessary to call this function, only if the time the constructor ran isn't desireable to be used as the start time.
Definition at line 90 of file TimeoutTimer.cpp.
|
private |
Definition at line 214 of file TimeoutTimer.hpp.
Referenced by asIntMs().
|
private |
Definition at line 213 of file TimeoutTimer.hpp.
|
private |
Definition at line 212 of file TimeoutTimer.hpp.
Referenced by asIntMs().
1.8.18