(make-thread (lambda () (write-line "Hello, world")))
Class precedence list:
thread, structure-object, t
Thread type. Do not rely on threads being structs as it may change in future versions.
Return a list of the live threads. Note that the return value is potentially stale even before the function returns, as new threads may be created and old ones may exit at any time.
Return
t
ifthread
is still alive. Note that the return value is potentially stale even before the function returns, as the thread may exit at any time.
Name of a
queue
. Can be assingned to usingsetf
. Queue names can be arbitrary printable objects, and need not be unique.
Create a new thread of
name
that runsfunction
. When the function returns the thread exits. The return values offunction
are kept around and can be retrieved byjoin-thread
.
Suspend current thread until
thread
exits. Returns the result values of the thread function. If the thread does not exit normally, returndefault
if given or else signaljoin-thread-error
.
Interrupt the live
thread
and make it runfunction
. A moderate degree of care is expected for use ofinterrupt-thread
, due to its nature: if you interrupt a thread that was holding important locks then do something that turns out to need those locks, you probably won't like the effect.function
runs with interrupts disabled, butwith-interrupts
is allowed in it. Keep in mind that many things may enable interrupts (GET-MUTEX when contended, for instance) so the first thing to do is usually awith-interrupts
or awithout-interrupts
. Within a thread interrupts are queued, they are run in same the order they were sent.
Terminate the thread identified by
thread
, by causing it to runsb-ext:quit
-
the usual cleanup forms will be evaluated
Return the local value of
symbol
inthread
, and a secondary value oft
on success.If the value cannot be retrieved (because the thread has exited or because it has no local binding for NAME) and
errorp
is true signals an error of typesymbol-value-in-thread-error
; iferrorp
is false returns a primary value ofnil
, and a secondary value ofnil
.Can also be used with
setf
to change the thread-local value ofsymbol
.
symbol-value-in-thread
is primarily intended as a debugging tool, and not as a mechanism for inter-thread communication.
Class precedence list:
thread-error, error, serious-condition, condition, t
Conditions of type
thread-error
are signalled when thread operations fail. The offending thread is initialized by the:thread
initialization argument and read by the functionthread-error-thread
.
Return the offending thread that the
thread-error
pertains to.