Programming around time flowing backward

One of the reasons you should always call Now when a delay returns is that it is possible for the flow of time to reverse direction. If you do not want your thread to continue processing when the flow of time reverses direction, you can do the following when you use delays:

  1. Call Now on the clock before you set the delay and save the value.
  2. Set the delay on the clock.
  3. When the delay returns, call Now and compare the time to the previous time.
    Assuming time was initially flowing forward, the flow of time has reversed direction if the current time is less than the start time. The delay returns because the delay time is now in the past (directionally less than the current time).
  4. If the clock has reversed direction, delay until negative infinity.
    The thread blocks until the direction changes again.
  5. The delay returns when the clock reverses direction.
    You can call Now to determine the current time and set an additional delay, or you can let your thread resume processing.

[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