Timers and time events

In some applications, agents are regularly activated at a predefined rate. For example, a clock animator is activated every second, and the scheduler in a time-sharing system switches control to the next process after a certain time quota elapses. In order to facilitate the description of time-related behavior of agents, B-Prolog provides timers. In order to create a timer, use the predicate
      timer(T,Interval)
where T is a variable, and Interval is an integer that specifies the rate of the timer. A timer runs as a separate thread. The call timer(T,Interval) binds T to a Prolog term that represents the thread. A timer starts ticking immediately after being created. It posts an event time(T) after every Interval milliseconds. A timer stops posting events after the call timer_stop(T). A stopped timer can be started again. A timer is destroyed after the call timer_kill(T) is executed.



Subsections
Neng-Fa Zhou 2013-01-25