bordeaux-threads

API Reference

bordeaux-threads

Bordeaux Threads makes writing portable multi-threaded apps simple.

BORDEAUX-THREADS

BORDEAUX-THREADS is a proposed standard for a minimal
  MP/threading interface. It is similar to the CLIM-SYS threading and
  lock support, but for the following broad differences:

  1) Some behaviours are defined in additional detail: attention has
     been given to special variable interaction, whether and when
     cleanup forms are run. Some behaviours are defined in less
     detail: an implementation that does not support multiple
     threads is not required to use a new list (nil) for a lock, for
     example.

  2) Many functions which would be difficult, dangerous or inefficient
     to provide on some implementations have been removed. Chiefly
     these are functions such as thread-wait which expect for
     efficiency that the thread scheduler is written in Lisp and
     'hookable', which can't sensibly be done if the scheduler is
     external to the Lisp image, or the system has more than one CPU.

  3) Unbalanced ACQUIRE-LOCK and RELEASE-LOCK functions have been
     added.

  4) Posix-style condition variables have been added, as it's not
     otherwise possible to implement them correctly using the other
     operations that are specified.

  Threads may be implemented using whatever applicable techniques are
  provided by the operating system: user-space scheduling,
  kernel-based LWPs or anything else that does the job.

  Some parts of this specification can also be implemented in a Lisp
  that does not support multiple threads. Thread creation and some
  thread inspection operations will not work, but the locking
  functions are still present (though they may do nothing) so that
  thread-safe code can be compiled on both multithread and
  single-thread implementations without need of conditionals.

  To avoid conflict with existing MP/threading interfaces in
  implementations, these symbols live in the BORDEAUX-THREADS package.
  Implementations and/or users may also make them visible or exported
  in other more traditionally named packages.
  • Variable *SUPPORTS-THREADS-P*
    nil
    This should be set to T if the running instance has thread support.
  • Variable *DEFAULT-SPECIAL-BINDINGS*
    nil
    This variable holds an alist associating special variable symbols to forms to evaluate. Special variables named in this list will be locally bound in the new thread before it begins executing user code. This variable may be rebound around calls to MAKE-THREAD to add/alter default bindings. The effect of mutating this list is undefined, but earlier forms take precedence over later forms for the same symbol, so defaults may be overridden by consing to the head of the list.
  • Variable *STANDARD-IO-BINDINGS*
    (list (cons '*package* '(find-package :common-lisp-user))
          (cons '*print-array* 't) (cons '*print-base* '10)
          (cons '*print-case* ':upcase) (cons '*print-circle* 'nil)
          (cons '*print-escape* 't) (cons '*print-gensym* 't)
          (cons '*print-length* 'nil) (cons '*print-level* 'nil)
          (cons '*print-lines* 'nil) (cons '*print-miser-width* 'nil)
          (cons '*print-pprint-dispatch* '(copy-pprint-dispatch nil))
          (cons '*print-pretty* 'nil) (cons '*print-radix* 'nil)
          (cons '*print-readably* 't) (cons '*print-right-margin* 'nil)
          (cons '*read-base* '10)
          (cons '*read-default-float-format* ''single-float) (cons '*read-eval* 't)
          (cons '*read-suppress* 'nil) (cons '*readtable* '(copy-readtable nil)))
    Standard bindings of printer/reader control variables as per CL:WITH-STANDARD-IO-SYNTAX.
  • Type THREAD
  • Function CURRENT-THREAD
  • Function THREADP (object)
  • Function THREAD-NAME (thread)
  • Function MAKE-LOCK (&optional name)
  • Function ACQUIRE-LOCK (lock &optional (wait-p t))
  • Function RELEASE-LOCK (lock)
  • Macro WITH-LOCK-HELD ((place) &body body)
  • Function MAKE-RECURSIVE-LOCK (&optional name)
  • Macro WITH-RECURSIVE-LOCK-HELD ((place) &body body)
  • Function MAKE-CONDITION-VARIABLE (&key name)
  • Function CONDITION-WAIT (condition-variable lock &key timeout)
  • Function CONDITION-NOTIFY (condition-variable)
  • Function THREAD-YIELD
  • Type TIMEOUT
  • Macro WITH-TIMEOUT ((timeout) &body body)
  • Function ALL-THREADS
  • Function INTERRUPT-THREAD (thread function &rest args)
  • Function DESTROY-THREAD (thread)
  • Function THREAD-ALIVE-P (thread)
  • Function JOIN-THREAD (thread)
  • Function START-MULTIPROCESSING
  • Function START-MULTIPROCESSING
  • Function MAKE-THREAD (function &key name (initial-bindings *default-special-bindings*))
  • Function MAKE-THREAD (function &key name (initial-bindings *default-special-bindings*))
  • Function CURRENT-THREAD
  • Function CURRENT-THREAD
  • Function THREADP (object)
  • Function THREADP (object)
  • Function THREAD-NAME (thread)
  • Function THREAD-NAME (thread)
  • Function MAKE-LOCK (&optional name)
  • Function MAKE-LOCK (&optional name)
  • Function ACQUIRE-LOCK (lock &optional wait-p)
  • Function ACQUIRE-LOCK (lock &optional wait-p)
  • Function RELEASE-LOCK (lock)
  • Function RELEASE-LOCK (lock)
  • Macro WITH-LOCK-HELD ((place) &body body)
  • Macro WITH-LOCK-HELD ((place) &body body)
  • Function MAKE-RECURSIVE-LOCK (&optional name)
  • Function MAKE-RECURSIVE-LOCK (&optional name)
  • Function ACQUIRE-RECURSIVE-LOCK (lock)
  • Function ACQUIRE-RECURSIVE-LOCK (lock)
  • Function RELEASE-RECURSIVE-LOCK (lock)
  • Function RELEASE-RECURSIVE-LOCK (lock)
  • Macro WITH-RECURSIVE-LOCK-HELD ((place &key timeout) &body body)
  • Macro WITH-RECURSIVE-LOCK-HELD ((place &key timeout) &body body)
  • Function THREAD-YIELD
  • Function THREAD-YIELD
  • Function MAKE-CONDITION-VARIABLE (&key name)
  • Function MAKE-CONDITION-VARIABLE (&key name)
  • Function CONDITION-WAIT (condition-variable lock &key timeout)
  • Function CONDITION-WAIT (condition-variable lock &key timeout)
  • Function CONDITION-NOTIFY (condition-variable)
  • Function CONDITION-NOTIFY (condition-variable)
  • Macro WITH-TIMEOUT ((timeout) &body body)
  • Macro WITH-TIMEOUT ((timeout) &body body)
  • Function ALL-THREADS
  • Function ALL-THREADS
  • Function INTERRUPT-THREAD (thread function)
  • Function INTERRUPT-THREAD (thread function)
  • Function DESTROY-THREAD (thread)
  • Function DESTROY-THREAD (thread)
  • Function THREAD-ALIVE-P (thread)
  • Function THREAD-ALIVE-P (thread)
  • Function JOIN-THREAD (thread)
  • Function JOIN-THREAD (thread)