Bordeaux-Threads

Version 0.8.8

Common Lisp threading library

Function: MAKE-THREAD

Syntax:

make-thread function &key name initial-bindings trap-conditions => thread

Arguments and values:

function -> a function designator.
name -> a string or nil.
initial-bindings -> an alist mapping special variable names to values. Defaults to *default-special-bindings*.
trap-conditions -> if true, wrap the thread function in a handler-case.

Description:

Creates and returns a thread named name, which will call the function function with no arguments: when function returns, the thread terminates.

The interaction between threads and dynamic variables is in some cases complex, and depends on whether the variable has only a global binding (as established by e.g. defvar/defparameter/top-level setq) or has been bound locally (e.g. with let or let*) in the calling thread.

  • Global bindings are shared between threads: the initial value of a global variable in the new thread will be the same as in the parent, and an assignment to such a variable in any thread will be visible to all threads in which the global binding is visible.

  • Local bindings, such as the ones introduced by initial-bindings, are local to the thread they are introduced in, except that

  • Local bindings in the the caller of make-thread may or may not be shared with the new thread that it creates: this is implementation-defined. Portable code should not depend on particular behaviour in this case, nor should it assign to such variables without first rebinding them in the new thread.

Exceptional situations:

An error of type type-error will be signaled if function is not a function designator.
An error of type type-error will be signaled if name is anything other than nil or a string.

Affected by:

*default-special-bindings*.

See also:

join-thread

Notes:

The threading model is implementation-dependent.

Last updated on 2022-01-07
Published on 2022-01-07
Edit on GitHub