[Next] [Up] [Previous] [Contents] [Index]
Next: Example: Up: Action Rules and Events Previous: Another example   Contents   Index

Timers and time events

In some applications, agents are activated regularly 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. To facilitate the description of time-related behavior of agents, B-Prolog provides timers. 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) in 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
[Next] [Up] [Previous] [Contents] [Index]
Next: Example: Up: Action Rules and Events Previous: Another example   Contents   Index
Neng-Fa Zhou () 2007-06-05