Next: , Up: Threading


11.1 Threading basics

     (make-thread (lambda () (write-line "Hello, world")))

— Structure: sb-thread:thread

Class precedence list: thread, structure-object, t

Thread type. Do not rely on threads being structs as it may change in future versions.

— Variable: sb-thread:*current-thread*

Bound in each thread to the thread itself.

— Function: sb-thread:make-thread function &key name

Create a new thread of name that runs function. When the function returns the thread exits. The return values of function are kept around and can be retrieved by join-thread.

— Function: sb-thread:join-thread thread &key default

Suspend current thread until thread exits. Returns the result values of the thread function. If the thread does not exit normally, return default if given or else signal join-thread-error.

— Condition: sb-thread:join-thread-error

Class precedence list: join-thread-error, error, serious-condition, condition, t

Joining thread failed.

— Function: sb-thread:join-thread-error-thread condition

The thread that we failed to join.

— Function: sb-thread:thread-alive-p thread

Check if thread is running.

— Function: sb-thread:list-all-threads

Return a list of the live threads.

— Condition: sb-thread:interrupt-thread-error

Class precedence list: interrupt-thread-error, error, serious-condition, condition, t

Interrupting thread failed.

— Function: sb-thread:interrupt-thread-error-thread condition

The thread that was not interrupted.

— Function: sb-thread:interrupt-thread thread function

Interrupt the live thread and make it run function. A moderate degree of care is expected for use of interrupt-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: sb-thread:terminate-thread thread

Terminate the thread identified by thread, by causing it to run sb-ext:quit - the usual cleanup forms will be evaluated