- pengine_collect(-Results, +Options) is det
- pengine_collect(?Template, +Goal, -Results, +Options) is det
- Collects Prolog engine results. Repackages the collect predicate
used by the Prolog engine tests. There is only one minor difference.
The number of replies maps to replies/1 in Options. Succeeds if not
provided but unites with the integer number of replies from all
engines whenever passed to Options. Options partitions into three
sub-sets: next options, state options and ask options.
The implementation utilises a mutable state dictionary to pass
event-loop arguments and accumulate results. So quite useful. Note
also that the second Goal argument is not module sensitive. There
consequently is no meta-predicate declaration for it.
The arity-2 form of pengine_collect expects that the pengine_create
options have asked a query. Otherwise the collect waits indefinitely
for the engines to stop.
It is possible that the engine could exit before the collector
asks for results. Prolog engines operate asynchronously. The collect
handler pre-empts failure and avoids an ask-triggered exception by
only asking existing engines for results. This does not eliminate
the possibility entirely. It only narrows the window of opportunity
to the interval in-between checking for existence and asking.
|- are the result terms, a list of successful Goal results
accumulated by appending results from all the running engines.
- pengine_wait(Options) is semidet
- Waits for Prolog engines to die. It takes time to die. If alive,
wait for the engines by sampling the current engine and child
engines periodically. Options allows you to override the default
number of retries (10) and the default number of retry delays (10
milliseconds). Fails if times out while waiting for engines to die;
failure means that engines remain alive (else something when wrong).
The implementation makes internal assumptions about the pengines
module. It accesses the dynamic and volatile predicates
current_pengine/6 and child/2. The latter is thread local.
The following predicates are exported, but not or incorrectly documented.
- pengine_collect(Arg1, Arg2, Arg3, Arg4)