Implementing
a clock
To implement a new clock, you derive a new clock type from TClock or TSyncableClock.
When you use TClock, you override the standard clock functions: Now, DelayUntil, and Clone. To support the Syncable Clock framework, you also implement GetClockSurrogate. By deriving a new time source that has the same timing as your clock, you can implement GetClockSurrogate by getting a clock surrogate for the time source.
You must also override the following private functions to support delays on the clock:
- CancelableDelayUntil is the same as DelayUntil except that the semaphore must be released before the task is blocked and after the request for the wakeup of the delay has been placed. That guarantees that TDelay will not have race conditions when Cancel is called.
- CancelDelay attempts to cancel the delay. It returns True if the delay is canceled, otherwise it returns False.
- CreateCancelDelayToken is used for CancelableDelayUntil and CancelDelay.
If you use TSyncableClock, you need to call the inherited functions in any functions that you override. You can layer additional functionality, but you cannot entirely replace the TSyncableClock functions.
[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