Clocks

Clocks provide the interface for the two main uses of the Time services: getting the current time and delaying until a specific time. A clock represents the flow of time by counting time from some point in time or event. For example, TSystemClock is a real-time clock that counts time from the boot of the system.

Generally, a clock has a corresponding time source that actually implements the source of the time. A time source can be viewed as a software implementation of a set of hardware services for getting the time and implementing delays.

TClock is an abstract base class that defines the clock protocol for getting the time and setting delays on a clock. The system provides three standard clocks derived from TClock: TSystemClock, TDateTimeClock, and TSyncableClock. A related class, TStopwatch, is not a true clock but a convenience class provided for calculating elapsed times.

TSystemClock

TSystemClock is a real-time clock that counts time from the boot of the system. Use the system clock when you need to perform standard timing operations, such as getting the current time and running time-dependent tasks.

TDateTimeClock

TDateTimeClock is a persistent clock that represents the flow of time in the international standard, UTC. Use the date-time clock to get the time of day as a localizable value. You use the international utilities to convert UTC time to local times. (See Text, Native Language Support, and Time Media for more information.)

You can also use TDateTimeClock when you need a persistent clock. The date-time clock counts time from 12:00 a.m., March 1, 2000, so times returned from this clock are negative (until 12:00 a.m. on March 1, 2000).

TSyncableClock

TSyncableClock is a clock that can be synchronized to other clocks. You can represent timing dependencies by setting up synchronization relationships between clocks. You use syncable clocks extensively when you work with time media.


TStopwatch

TStopwatch is a convenience class for calculating elapsed times--it represents a stopwatch used for timing intervals. An instance of TStopwatch starts running from time zero when it is created. Unless you specify another clock to use for timing, TStopwatch uses the system clock.

To specify a different clock, you pass a TClock* to the stopwatch constructor. The stopwatch does not adopt the clock, so the clock must not be destroyed until after the stopwatch is deleted.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker