[ Obsolete | Reference Manual | Alphabetic Index ]
Equivalent to once(Goal) but with mutual exclusion among parallel workers.
- Atom or compound term.
This built-in predicate is obsolete!
This built-in can be used in parallel programs to implement mutual
exclusion between parallel workers. A Goal that is called via mutex/2
can be sure that no parallel worker is executing at the same time any
goal that is protected by a mutex/2 with the same MutexId.
Note that in a side effect free program there is no need ever to worry
about mutual exclusion. Only when side effects are involved (e.g.
read/1,2 and write/1,2, assert/1, setval/2, record/2 etc.) it may be
necessary to acquire exclusive access to the common resource by using
Modes and Determinism
This predicate is sensitive to its module context (tool predicate, see @/2).
Fails if Goal fails
- (4) instantiation fault
- Goal is not instantiated.
- (5) type error
- Goal is not an atom or a compound term.
% make sure the list is printed in one chunk
write_list() :- nl.
write_list([X|Xs]) :- writeln(X), write_list(Xs).
mutex_init / 1, once / 1