A.54 library(thread): High level thread primitives
AllApplicationManualNameSummaryHelp

  • 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)
Sourceconcurrent_and(:Generator, :Test)
concurrent_and(:Generator, :Test, +Options)
Concurrent version of (Generator,Test). This predicate creates a thread providing solutions for Generator that are handed to a pool of threads that run Test for the different instantiations provided by Generator concurrently. The predicate is logically equivalent to a simple conjunction except for two aspects: (1) terms are copied from Generator to the test Test threads while answers are copied back to the calling thread and (2) answers may be produced out of order.

If the evaluation of some Test raises an exception, concurrent_and/2,3 is terminated with this exception. If the caller commits after a given answer or raises an exception while concurrent_and/2,3 is active with pending choice points, all involved resources are reclaimed.

Options:

threads(+Count)
Create a worker pool holding Count threads. The default is the Prolog flag cpu_count.

This predicate was proposed by Jan Burse as balance((Generator,Test)).