[comp.lang.smalltalk] ST/V clockEvent: SOLUTION!!

jhugart@umaxc.weeg.uiowa.edu (Jacob Hugart) (03/23/91)

Here's what to do:

In your model, have some method tell the Time class to start
generating clock interrupts.  This is done by the following
expression:

	Time clockTickPeriod: anIntegerNumberOfMilliseconds.

Then, the Dispatcher class, when it receives a timerInterrupt, will
send one of two messages (as far as I can tell).  It will either send
a clockEvent message, which basically means "I received an interrupt,"
or it will send a clockEvent: anInteger message, which means "I have
received anInteger number of interrupts since the last clockEvent I
sent you."  Your model must implement these methods.

You must shut off the clock interrupts yourself.  If you don't,
something very nasty will occur: Smalltalk will accumulate the
interrupts until its stack overflows, at which point you'll receive an
unrecoverable error and Smalltalk will quit.  To shut off the
interrupts, place the following expression in your close method:

	Time clockTicksOff.

For those of you using Smalltalk/V Macintosh, consult the
implementation of the Dashboard example.  It has a simple clock which
performs exactly this kind of clock ticking (*BOOM*).  It sparked me
towards this solution.

Thanks to those who helped by responding to my post.  You were right,
your assistance was appreciated.
--
Jacob Hugart  <jhugart@umaxc.weeg.uiowa.edu>
Database Consulting Group, Weeg Computing Center, University of Iowa