The maximum duration of a Delay is limited by the size of a SmallInteger parameter passed to a primitive in the virtual machine. Class LongDelay implements delays of longer duration using a collection of Delays of the required total duration. LongDelay attempts to mimic the behavior of a Delay, including proper cleanup when a waiting process is terminated prior to expiration of the LongDelay.
A LongDelay keeps a list of short delays, with a process that waits for all the short delays to expire. The process is given a meaningful name in the ProcessBrowser in order to reduce the risk of accidentally terminating a valid delay watcher process.
To wait for one year, evaluate: (Delay forSeconds: 365 days asSeconds) wait
To see how it works without waiting for a year: | time1 time2 | LongDelay initializeForTesting. time1 _ Time millisecondClockValue. (LongDelay forMilliseconds: 5731) wait inspect. time2 _ Time millisecondClockValue. LongDelay initialize. self notify: 'LongDelay returned after ', (time2 - time1) asString, ' milliseconds'.
The actual duration of a scheduled LongDelay may have inaccuracies due to cumulative errors of its sequential short Delays.
A LongDelay relies on a process to wait for the expiration of its sequential short Delays. If this process is terminated, the LongDelay will not complete normally. The process is given a recognizable name in order to reduce the likelihood of accidental termination.
Other changes introduced by this change set: - force to integer parameters when creating a Delay (all methods) - add Delay>>#printOn: to display duration of the delay - add Delay class>>maxVal to specify maximum duration of short Delay - instantiate Delay or LongDelay as required based on duration
Dave
squeak-dev@lists.squeakfoundation.org