• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

A.59 library(thread): High level thread primitives
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(thread): High level thread primitives
          • concurrent/3
          • concurrent_forall/2
          • concurrent_forall/3
          • concurrent_and/2
          • concurrent_and/3
          • concurrent_maplist/2
          • concurrent_maplist/3
          • concurrent_maplist/4
          • first_solution/3
          • call_in_thread/2
    • Packages
Availability::- use_module(library(thread)).(can be autoloaded)
Source[semidet]concurrent_forall(:Generate, :Action)
[semidet]concurrent_forall(:Generate, :Action, +Options)
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.
ClioPatria (version V3.1.1-51-ga0b30a5)