Implements a timeout mechanism via sigalarm.
More...
#include <timer.H>
|
| | timer (unsigned int seconds) |
| | Construct with specified time-out, a value of 0 makes it a no-op.
|
| | ~timer () |
| | Destructor. Restores the alarm and signal handler as required.
|
|
| unsigned int | timeOut_ |
| | The time-out value (seconds). Needed by macro timedOut.
|
|
| static int | debug |
| | Named/registered debug switch: 'timer'.
|
| static jmp_buf | envAlarm |
| | State for setjmp. Needed by macro timedOut.
|
Implements a timeout mechanism via sigalarm.
Example usage:
..
{
}
else
{
}
timer(unsigned int seconds)
Construct with specified time-out, a value of 0 makes it a no-op.
#define timedOut(x)
Check if timeout has occurred.
Constructor set signal handler on sigalarm and alarm(). Destructor clears these.
- Warning
- The setjmp restores complete register state so including local vars held in regs. So if in blocking part something gets calced in a stack based variable make sure it is declared 'volatile'.
- Note
- timedOut is macro because setjmp can't be in member function of timer. ?something to do with stack frames.
- Source files
-
Definition at line 82 of file timer.H.
◆ timer()
| timer |
( |
unsigned int | seconds | ) |
|
|
explicit |
Construct with specified time-out, a value of 0 makes it a no-op.
◆ ~timer()
Destructor. Restores the alarm and signal handler as required.
◆ debug
Named/registered debug switch: 'timer'.
Definition at line 107 of file timer.H.
◆ timeOut_
The time-out value (seconds). Needed by macro timedOut.
Definition at line 112 of file timer.H.
◆ envAlarm
State for setjmp. Needed by macro timedOut.
Definition at line 117 of file timer.H.
The documentation for this class was generated from the following file:
- src/OSspecific/POSIX/signals/timer.H