Next: Special Variables, Up: Threading
(make-thread (lambda () (write-line "Hello, world")))
Class precedence list:
thread, structure-object, tThread 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
tifthreadis 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
namethat runsfunction. When the function returns the thread exits. The return values offunctionare kept around and can be retrieved byjoin-thread.
Suspend current thread until
threadexits. Returns the result values of the thread function. If the thread does not exit normally, returndefaultif given or else signaljoin-thread-error.
Interrupt the live
threadand 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.functionruns with interrupts disabled, butwith-interruptsis 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-interruptsor 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
symbolinthread, and a secondary value ofton success.If the value cannot be retrieved (because the thread has exited or because it has no local binding for NAME) and
errorpis true signals an error of typesymbol-value-in-thread-error; iferrorpis false returns a primary value ofnil, and a secondary value ofnil.Can also be used with
setfto change the thread-local value ofsymbol.
symbol-value-in-threadis primarily intended as a debugging tool, and not as a mechanism for inter-thread communication.
Class precedence list:
thread-error, error, serious-condition, condition, tConditions of type
thread-errorare signalled when thread operations fail. The offending thread is initialized by the:threadinitialization argument and read by the functionthread-error-thread.
Return the offending thread that the
thread-errorpertains to.