ELPA Logo GNU ELPA: futur

futur Atom Feed

Description
Future/promise-based async library
Latest
futur.tar (.sig), 2026-Aug-10, 0.01 KiB
Maintainer
Stefan Monnier <monnier@iro.umontreal.ca>
Other versions:
development version
Website
https://elpa.gnu.org/packages/futur.html
ELPA's Repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

Futur is a library to try and make async programming a bit easier. It is inspired from Javscript's async/await, Haskell's monads, and ConcurrentML's events.

You can create trivial futures with futur-done. You can create a "process future" with futur-process-call. And the main way to use futures is to compose them with futur-let*, which can be used as follows:

(futur-let*
    ((buf (current-buffer))
     (exitcode1 <- (futur-process-call CMD1 nil buf nil ARG1 ARG2))
     (out (with-current-buffer buf
            (buffer-string)))  ;; Get the process's output.
     (exitcode2 <- (futur-process-call CMD2 nil buf nil ARG3 ARG4)))
  (with-current-buffer buf
    (concat out (buffer-string))))

This example builds a future which runs two commands in sequence. For those rare cases where you really do need to block everything else and wait for a future to complete, you can use futur-blocking-wait-to-get-result.

The minor more futur-hacks-mode inserts itself into a few Emacs features to make them use futures. The intention is for those to eventually get integrated directly into Emacs or be dropped, but it is also meant as a testbed for the library.

Low level API

Composing futures

Predefined future constructors

Running ELisp concurrently in subprocesses

Related packages

BUGS

Old versions

futur-1.7.tar.lz2026-Apr-2930.6 KiB
futur-1.4.tar.lz2026-Mar-2227.5 KiB
futur-1.3.tar.lz2026-Mar-1625.4 KiB
futur-1.2.tar.lz2026-Mar-1124.5 KiB
futur-1.1.tar.lz2026-Feb-2713.4 KiB
futur-1.0.tar.lz2026-Feb-1210.7 KiB

News

Version 2.0:

- New functions `futur-elisp-funcall' and `futur-elisp-sandbox-funcall'
  to run ELisp code concurrently in subprocesses.
- Better support for aborting futur-elisp subprocesses.
- New function `futur-catch-abort'.
- New function `futur-dbus-call-method'.

Version 1.5:

- New synchronization objects: full/empty cells and semaphores.
- New type for "mines" used internally for synchronization objects.
- Emit warnings for unused (non-nil) return values.
- New debug var `futur-elisp--include-extra-debug-info'.
- `futur-client.el' is now called `futur-elisp.el'.

Version 1.4:

- `:error-fun' renamed to `on-error' in `futur-let*'.
- New function `futur-register-unwind-protect`.
- `futur-hacks-mode' now also makes `byte-compile-file' asynchronous.
- Bug fixes.

Version 1.3:

- Syntax of `:error-fun' changed in `futur-let*'.
- Remove `idle' argument from `futur-timeout'.
- Adjusted `futur-hacks-mode' to changes in Emacs `master'.

Version 1.2:

- `futur-abort' takes a second argument (the reason for the abortion).
- New function `futur-funcall'.
- `futur-bind' and `futur-blocking-wait-to-get-result' can now select
  which errors they catch.
- New function `futur-p'.
- Preliminary support to run ELisp code in subproceses&sandboxes.
- Experimental `futur-hacks-mode' using the preliminary sandbox code.
- New var `futur-use-threads' to be able to force the use of timers.

Version 1.1:

- New functions: `futur-race', `futur-sit-for', `futur-url-retrieve'.
- New function `futur-concurrency-bound' when you need to limit concurrency.
- Rename `futur-error' to `futur-failed'.
- Rename `futur-register-callback' to `futur--register-callback'.
- Rename `futur-ize' to `futur--ize'.
- Fix compatibility with Emacs<31.
- Minor bug fixes.

Version 1.0:

- After years of sitting in the dark, it's finally getting dusted up for
  a release.