Aw tick

From ActiveWiki
Revision as of 14:14, 26 October 2008 by Macavity (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Minimum requirements
Added in version 4.1
SDKbuild 53


unsigned int aw_tick (void)

Description

Returns the number of milliseconds that have elapsed since the SDK was initialized.

Callback

None (returns immediately)

Notes

This method provides a high precision reference time for time critical operations or application timers. The degree of precision depends largely on the operating system being used.

Precision (1) Operating system
1 ms Linux variants
1 ms Windows Vista
~10 ms Windows 2000, Windows XP and Windows 2003
~15 ms Windows NT 3.1
~50 ms Windows 95, Windows 98 and Windows ME

(1) Precision is defined as the smallest difference between tick counts from successive calls to this method.

The return value is always equal to or larger than one from a previous call, with one exception. As it is only a 32-bit number it will wrap around to zero after 49.7 days (or 0xFFFFFFFF milliseconds). This has the potential to cause problems in bots that run for extended periods.

Arguments

None

Argument attributes

None

Return values

Number of milliseconds that have elapsed since aw_init or aw_init_bind was called.

Returned attributes

None

Usage

while (1)
{
  aw_wait (1);
  /*
    The tick count is likely to go past 1000000 without assuming that exact value.
    It is not possible to use the == operator to test for a particular tick count.
  */
  if (aw_tick () >= 1000000) 
  {
    puts ("One million milliseconds have elapsed since the SDK was initialized!");
    break;
  }
}

See also