Section "timer"

With the introducing of the async API the Prolog interpreter is able to process promises when in async mode. So far sleep/1 is the first predicate that relinquishes control. Further opportunities for the future will be input/output predicates. Last but not least the frequent garbage collection can be used to relinquish control on a regular basis.

While there exists a primordial task “main”, the application programmer can create further tim-ers and/or tasks. The realization is via stack-less coroutines for timers and stack-full coroutines for tasks. The stack-less coroutines are executed inside their creator stack-full coroutine and are not allowed to yield.

The following timer predicates are provided:

sleep(D):
The predicate suspends execution for D seconds.
call_later(G, D):
call_later(G, D, T):
The predicate succeeds. As a side effect it schedules the goal G to be executed after D seconds. The ternary predicate succeeds in T with the scheduled timer.
timer_cancel(T):
The predicate succeeds. As a side effect it cancels the timer T.
call_with_time_limit(D, G):
The predicate succeeds once if G succeeds. If the goal has not terminated after D seconds a time limit system error is signalled to the goal.