Next: , Previous: , Up: Threads   [Contents][Index]

5.15.4 Manipulating Threads

Function: thread-yield

This function may be used to pass control away from the current thread if other threads are waiting to run. There is usually no need to call this function since running threads will be preempted after a period of time.

Function: thread-suspend #!optional thread milliseconds

Mark thread (or the current thread) as being suspended. It will not be selected until either it has had this status removed, or milliseconds milliseconds time has passed.

Suspending the current thread will pass control to the next runnable thread in the same dynamic root. If there are no runnable threads, then the interpreter will sleep until the next thread becomes runnable.

Function: thread-join thread #!optional timeout default-value

Suspends the current thread until either thread has exited, or timeout milliseconds have passed.

If thread exits normally, then the value of the last form it evaluated is returned; otherwise default-value is returned.

It is an error to call thread-join on a thread that is not a member of the current dynamic root.

Function: thread-wake thread

Remove the suspended state from thread thread. It will then be scheduled for execution sometime subsequently, if its dynamic root is active.

Function: thread-suspended-p thread

Returns true if thread is currently suspended.

Thread preemption may be forbidden at times, to allow atomic operations to take place. Each dynamic root has its own “forbid counter”. Only when this counter is zero may the current thread be preempted.

Function: thread-forbid

Increment the forbid count.

Function: thread-permit

Decrement the forbid count.

Macro: without-interrupts #!rest forms

Evaluate the list of forms forms with thread preemption temporarily disabled.

Next: , Previous: , Up: Threads   [Contents][Index]