Source file _ticker.icn

#  $Id: _ticker.icn,v 1.1 2003-05-31 06:09:04 jeffery Exp $

#
# A class for an object with a ticker.
# This class should be subclassed by a class that wishes to
# have a ticker facility, namely implement a method that is
# called repeatedly at set intervals.
#
class Ticker(
   ticker_rate,             # Ticker rate
   next_tick_time           # Time of next tick
   )

   ##
   #  This method should be overridden by the subclass.  It will
   #  be called repeatedly.
   #
   method tick()
      error("tick() must be overridden in subclass")
   end


   ##
   #  Start the ticker process, with the {tick()}
   #  method being invoked approximately every {n} milliseconds.
   #
   #  @param n   the ticker interval in milliseconds.
   #
   method set_ticker(n)
      dispatcher$set_ticker(self, n)
   end

   ##
   #  Stop the ticker.
   #
   method stop_ticker()
      dispatcher$stop_ticker(self)
   end

   ##
   #  Change the interval of the ticker
   #  @param n   the new interval.
   #
   method retime_ticker(n)
      dispatcher$retime_ticker(self, n)
   end

   ##
   #  Succeeds if and only if the ticker is active.
   #
   method is_ticking()
      return \ticker_rate
   end

   initially
end

This page produced by UniDoc on 2021/04/15 @ 23:59:44.