| |||||||||||
| Minerva supports timer handling. There exist a small set of predicates to support timer handling.
A timer can be created, deleted, started, stopped and the state of a timer (running or not running) can be checked. There is a user defined callback predicate, that can be bound to a timer. When a timer runs down, then this callback predicate will be called. Each timer is implemented as a thread. So timer callbacks may be fired asynchronously. However, there is no multithreading support in Minerva, that is: at any time Minerva can only execute one goal. Only when the execution of one goal has been finished another goal (maybe called from another thread) may be executed. Therefore, if you need timer support, then your program should have the following structure:
main(..) :-
...
timer_create(mycallback(_,...), Timer),
...
timer_start(Timer, T).
When executing your program you have to call Minerva with the program flag -daemon. This prevents, that Minerva stops execution when the main/1 predicate has been executed. Minerva will only be stopped when all of his threads have been stopped.
Examplemain(_) :- ticker. | |||||||||||
| |||||||||||
| Back> |
|