Did you know ... | Search Documentation: |
Packs (add-ons) for SWI-Prolog |
Title: | Easy concurrency |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 0.0.1 |
SHA1 sum: | ac15c286d83f0e6cf20a75e4443caa1127ec967c |
Author: | Michael Hendricks <michael@ndrix.org> |
Maintainer: | Michael Hendricks <michael@ndrix.org> |
Packager: | Michael Hendricks <michael@ndrix.org> |
Home page: | http://packs.ndrix.com/spawn/index.html |
Download URL: | http://packs.ndrix.com/spawn/spawn-0.0.1.tgz |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
0.0.1 | ac15c286d83f0e6cf20a75e4443caa1127ec967c | 195 | http://packs.ndrix.com/spawn/spawn-0.0.1.tgz |
:- use_module(library(spawn)). retirement(EmployeeId,Name,HireDate) :- % start long-running computations in the background spawn(query_company_ldap(EmployeeId,Employee)), spawn(query_hr_database(EmployeeId,Job)), do_something_productive_while_waiting, % extract desired details from Employee and Job % (blocks until background computations are done) Employee = employee(Name,_,_), Job = job(_,HireDate,_). some_numbers(PiN,Rand) :- % start long-running computations in the background async(calculate_nth_digit_of_pi(21_734,PiN),PiToken), async(ask_randomorg_for_a_number(Rand), RandToken), % explicitly block until they're done await(PiToken), writeln(PiN), % now it has a value await(RandToken), writeln(Rand). % now it has a value too
SWI Prolog has great concurrency primitives. For some common operations, those primitives are too low level. You end up reading through a lot of message queue and threading boilerplate code. This library provides high level concurrency predicates which handle all the messy details.
Our aim is to make this library as easy to use as call/1.
Using SWI-Prolog 6.3 or later:
?- pack_install(spawn).
This module uses semantic versioning.
Source code available and pull requests accepted at http://github.com/mndrix/spawn
Pack contains 6 files holding a total of 12.5K bytes.