|
The Pedigree Project
0.1
|
#include <TimeoutGuard.h>
Collaboration diagram for TimeoutGuard:Classes | |
| class | TimeoutGuardEvent |
Public Member Functions | |
| TimeoutGuard (size_t timeoutSecs) | |
| ~TimeoutGuard () | |
| bool | timedOut () |
| void | cancel () NORETURN |
Private Member Functions | |
| TimeoutGuard (const TimeoutGuard &) | |
| TimeoutGuard & | operator= (const TimeoutGuard &) |
Private Attributes | |
| TimeoutGuardEvent * | m_pEvent |
| bool | m_bTimedOut |
| SchedulerState | m_State |
| size_t | m_nLevel |
| Spinlock | m_Lock |
This class waits (in the background) for a given amount of time to elapse, then cancels whatever operation is currently taking place.
The class functions in a similar way to setjmp/longjmp, except using saveState/editState. The timeout is cancelled when the class goes out of scope.
Definition at line 45 of file TimeoutGuard.h.
| TimeoutGuard::TimeoutGuard | ( | size_t | timeoutSecs | ) |
Creates a new TimeoutGuard, with the given timeout, in seconds.
Definition at line 35 of file TimeoutGuard.cc.
References Timer::addAlarm(), Thread::getStateLevel(), Machine::getTimer(), Processor::information(), m_nLevel, m_pEvent, m_State, Processor::saveState(), and WARNING.
| TimeoutGuard::~TimeoutGuard | ( | ) |
Destroys the TimeoutGuard, cancelling the timeout.
Definition at line 60 of file TimeoutGuard.cc.
References Machine::getTimer(), Processor::information(), m_Lock, m_pEvent, and Timer::removeAlarm().
| void TimeoutGuard::cancel | ( | ) |
Cancels the current operation.
Definition at line 79 of file TimeoutGuard.cc.
References cancel(), FATAL, m_bTimedOut, m_pEvent, TimeoutGuard::TimeoutGuardEvent::m_pTarget, m_State, NOTICE, and Processor::restoreState().
Referenced by cancel().
Here is the caller graph for this function:
|
inline |
Returns true if the guard just timed out, false if not. This should be called just after the constructor.
Definition at line 56 of file TimeoutGuard.h.
References NORETURN.
|
private |
|
private |
Our own personal lock.
Definition at line 112 of file TimeoutGuard.h.
Referenced by ~TimeoutGuard().
|
private |
|
private |
The event, which will be automatically freed when it fires.
Definition at line 96 of file TimeoutGuard.h.
Referenced by cancel(), TimeoutGuard(), and ~TimeoutGuard().
|
private |
Saved state.
Definition at line 103 of file TimeoutGuard.h.
Referenced by cancel(), and TimeoutGuard().
1.8.11