File "tasks"

The channel objects here are provided so that tasks can communicate with each other. They provide blocking queues with a maximum size of one. The blocking is done inside in that the current tasks yields, and then gets suspended and resumes if the desired conditions are met. Or if an exception gets processed due to an abort.

Unlike timers which are assumed to perform short lived actions, tasks are offered to perform longer living actions. The Prolog systems maintains a list of the alive tasks, that can be queried with the predicate current_task/1. Tasks that are expected about to die, can be awaited with the predicate task_join/1 by multiple waiters.

The following tasks predicates are provided:

chan(C):
The predicate succeeds in C with a new channel. The channel can be used from within Dogelog tasks.
send(C, T):
The predicate succeeds. As a side effect the term T is sent to the channel C. The predicate blocks until the channel accepts the term.
recv(C, T):
The predicate succeeds. As a side effect the term T is received from the channel C. The predicate blocks until the channel provides the term T.
create_task(G):
create_task(G, T):
The predicate succeeds. As a side effect it schedules the goal G to be executed immedi-ately. The binary predicate succeeds in T with the new task.
current_task(T):
The predicate succeeds in T with the alive tasks.
task_join(T):
The predicate succeeds after the task T dies.