Node:Higher level thread procedures, Previous:Low level thread primitives, Up:Threads



32.4.2 Higher level thread procedures

Higher level thread procedures are available by loading the (ice-9 threads) module. These provide standardized thread creation and mutex interaction.

%thread-handler tag args... Scheme Procedure

This procedure is specified as the standard error-handler for make-thread and begin-thread. If the number of args is three or more, use display-error, otherwise display a message "uncaught throw to tag". All output is sent to the port specified by current-error-port.

Before display, global var the-last-stack is set to #f and signals are unmasked with unmask-signals.

[FIXME: Why distinguish based on number of args?! Cue voodoo music here.]

make-thread proc [args...] macro
Apply proc to args in a new thread formed by call-with-new-thread using %thread-handler as the error handler.

begin-thread first [rest...] macro
Evaluate forms first and rest in a new thread formed by call-with-new-thread using %thread-handler as the error handler.

with-mutex m [body...] macro
Lock mutex m, evaluate body, and then unlock m. These sub-operations form the branches of a dynamic-wind.

monitor first [rest...] macro
Evaluate forms first and rest under a newly created anonymous mutex, using with-mutex.

[FIXME: Is there any way to access the mutex?]