- concurrent_forall(:Generate, :Action) is semidet
- concurrent_forall(:Generate, :Action, +Options) is semidet
- True when Action is true for all solutions of Generate. This has the
same semantics as forall/2, but the Action goals are executed in
multiple threads. Notable a failing Action or a Action throwing an
exception signals the calling thread which in turn aborts all
workers and fails or re-throws the generated error. Options:
- threads(+Count)
- Number of threads to use. The default is determined by the
Prolog flag
cpu_count
.
- To be done
- - Ideally we would grow the set of workers dynamically, similar
to dynamic scheduling of HTTP worker threads. This would avoid
creating threads that are never used if Generate is too slow or does
not provide enough answers and would further raise the number of
threads if Action is I/O bound rather than CPU bound.