Eager Future is a Common Lisp library for concurrent programming with composable, eager futures (look here for a thorough discussion of what exactly that means).
Eager Future is a rewrite of Marijn Haverbeke's PCall library. The main differences between Eager Future and PCall are:
EXECUTION-ERROR, which is raised when the
future is asked to YIELD.Eager Future is built on the assumption that multi-core chips will provide a friendly habitat for speculative execution and many live threads.
The latest version of Eager Future is 0.4. Older versions can be downloaded from the release directory.
Eager Future is available
via ASDF-Install: (asdf-install:install
:eager-future)
The Eager Future repository can be checked out with darcs:
darcs get http://common-lisp.net/project/eager-future/repository/eager-future/
Questions should be directed to the eager-future-devel mailing list.
PCALL function
FUTURE that
can later be used to retrieve the result of executing the
function. Note that the execution of the function takes places in
an
unspecified dynamic
environment.PEXEC (&body body)
(pcall (lambda () ...)).PLET ((bindings) &body body)
LET, but all bindings are evaluated
asynchronously.YIELD future
FUTURE, returns the
value(s) that resulted from executing the function associated with
that future. If execution has not yet finished, blocks until it
has. If a condition was raised during
execution, YIELD will raise a condition of
type EXECUTION-ERROR that wraps the original
condition (which can be examined by
calling EXECUTION-ERROR-CAUSE on
the EXECUTION-ERROR).READY-TO-YIELD? future
T if the future can YIELD
without blocking, NIL otherwise.SELECT (&rest futures)
YIELD without blocking.*THREAD-POOL*
PCALLed futures are
run in. An instance of THREAD-POOL by default. Each
thread pool class has a THREAD-LIMIT slot, which has
class-specific behavior.THREAD-POOL
THREAD-LIMIT is nil (the default),
any newly spawned threads are never released from the thread
pool. When an integer, indicates the desired size of the thread
pool - any idle threads above this limit are freed.FIXED-FIFO-THREAD-POOL
FIXED-FIFO-THREAD-POOL inappropriate for use
when composing timing-sensitive futures with
SELECT. When THREAD-LIMIT is nil (the
default), the size of the thread pool is unbounded. Otherwise it
must be an integer indicating the maximum size of the pool.(defun do-something (with-timeout)
(yield (select (pcall #'heavy-io-or-compute-bound-function)
(pexec (sleep with-timeout) :timed-out))))
The above function DO-SOMETHING illustrates how
futures can be composed to provide soft real-time bounds for
asynchronous computations.
Eager Future is maintained by Vladimir Sedach.
Eager Future is licensed under the terms of the zlib license. Details are contained in the LICENSE file, included with the distribution.