indexing description: "[ EM_TIMER is used by EM_TIME to hold a list of callbacks. ]" date: "$Date$" revision: "$Revision$" class EM_TIMER inherit COMPARABLE EM_TIME_SINGLETON undefine is_equal end create make feature {NONE} --creation make (an_integer: INTEGER; an_action: FUNCTION[ANY, TUPLE[INTEGER], INTEGER]) is -- Create a EM_TIMER with callback `an_action' that is triggered every `an_integer' milliseconds require positiv_interval: an_integer > 0 an_action_not_void: an_action /= void do interval := an_integer next_trigger_time := interval + time.ticks callback := an_action ensure interval = an_integer callback = an_action -- next_trigger_time = interval + time.ticks end feature -- status infix "<" (other: like Current): BOOLEAN is -- Is current EM_TIMER less than other? do Result := next_trigger_time < other.next_trigger_time end feature {EM_TIME, EM_TIMER} -- status next_trigger_time: INTEGER -- Next time in millisecond when the callback is will be called set_next_trigger_time (an_integer: INTEGER) is -- Set `next_trigger_time' require an_integer > next_trigger_time do next_trigger_time := an_integer ensure next_trigger_time = an_integer end interval: INTEGER -- The `interval' in milliseconds between two calls of the `callback' set_interval (an_integer: INTEGER) is -- set interval to `an_interval' require an_integer > 0 do interval := an_integer ensure interval = an_integer end callback: FUNCTION[ANY, TUPLE[INTEGER], INTEGER] -- The function to be called at `next_trigger_time' end