Module "cond"

Some of the locks can produce condition variables via the predicate cond_new/2. As a convenience a pair of a lock and condition variable can be created by the predicate monitor_new/2. The resulting object is suitable both for the lock predicates from the module "lock" and for the condition variable predicates from this module.

A condition variable allows a thread to temporarily leave a critical region via the predicates cond_wait/1 and cond_wait_timeout/2. The predicates cond_notify/1 and cond_notify_all/1 on the other hand let a waiting thread respectively all waiting threads enter their critical region again.

The following monitor predicates are provided:

monitor_new(M):
The predicate succeeds in M with a new monitor. The monitor implements the Java Lock interface and the Java Condition interface at the same time.
cond_new(L, C):
The predicate succeeds in C with a new condition for the lock L.
cond_wait(C):
The predicate succeeds when the condition C was notified.
cond_wait_timeout(C, T):
The predicate succeeds when the condition C was notified in the time-out T. Otherwise the predicate fails.
cond_notify(C):
The predicate succeeds in notifying one thread waiting on C.
cond_notify_all(C):
The predicate succeeds in notifying all threads waiting on C.

The following monitor evaluable functions are provided:

current_time:
Returns the current time in milliseconds.

Kommentare