Class DTimer

Inherits from:
Object
Declared in:
DTimer.h

Class Hierarchy

    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

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0