- Inherits from:
- Object
- Declared in:
- DTimer.h
Object
|
+---DTimer
Class Description
The timer class implements a number of methods for creating and polling a
timer. Maximum resolution: << 10000 seconds. The class can also be used to
delay execution for a while.
- Example:
#include <stdio.h>
#include "ofc/DTimer.h"
int main(int argc, char *argv[])
{
DTimer *tmr = [DTimer alloc];
[tmr init :150]; // Init with a timeout value of 150 msec
[tmr restart]; // Restart the timer
[DTimer delay :80]; // Wait 80 msec
// Check if the timer is expired
printf("Timer %s expired.\n", ([tmr isExpired] ? "is" : "is not"));
printf("Timer time:%ld.\n", [tmr timer]); // Get the current timer time
[DTimer delay :80]; // Wait another 80 msec -> 160 msec waited
// Check again if the timer is expired
printf("Timer %s expired.\n", ([tmr isExpired] ? "is" : "is not"));
[tmr free]; // Cleanup
return 0;
}
- Last modified:
- 04-Aug-2008 (DTimer.h)
Instance Variables
- private long _now
- last timer check in msec
- private long _timeOut
- time out value in msec
- private long _remaining
- remaing msec during last timer check
- Class Methods
- + (void) delay :(long) msec
- Delay for a certain time
- Parameters:
- msec - the number of milliseconds to wait
- Constructors
- - (DTimer *) init
- Initialise a default timer
- Returns:
- the object
- - (DTimer *) init :(long) timeOut
- Initialise the timer with a timer-out value
- Parameters:
- timeOut - the time out value (in milliseconds)
- Returns:
- the object
- Members
- - (long) timeOut
- Get the time out value (in milliseconds)
- Returns:
- the time out value (0 for uninitialised)
- - (DTimer *) timeOut :(long) timeOut
- Set the time out value (in milliseconds)
- Parameters:
- timeOut - the time out value
- Returns:
- the object
- - (long) timer
- Get the timer value (time since last expire/restart)
- Returns:
- the timer (in millseconds)
- Main methods
- - (BOOL) isExpired
- Test for timer expiration; if so the timer is reset
- Returns:
- Is the timer expired
- - (BOOL) isExpired :(long) timeOut
- Test for timed expiration; if so the timer is reset
- Parameters:
- timeOut - the time out value (in milliseconds)
- Returns:
- is the timer expired ?
- - (DTimer *) restart
- Restart the timer
- Returns:
- the object
generated 06-Sep-2008 by ObjcDoc 3.0.0