www.delorie.com/gnu/docs/guile/guile_370.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

32.4.1 Low level thread primitives

Scheme Procedure: call-with-new-thread thunk error-handler
Evaluate (thunk) in a new thread, and new dynamic context, returning a new thread object representing the thread.

If an error occurs during evaluation, call error-handler, passing it an error code describing the condition. [Error codes are currently meaningless integers. In the future, real values will be specified.] If this happens, the error-handler is called outside the scope of the new root -- it is called in the same dynamic context in which with-new-thread was evaluated, but not in the caller's thread.

All the evaluation rules for dynamic roots apply to threads.

Scheme Procedure: join-thread thread
Suspend execution of the calling thread until the target thread terminates, unless the target thread has already terminated.

Scheme Procedure: yield
If one or more threads are waiting to execute, calling yield forces an immediate context switch to one of them. Otherwise, yield has no effect.

Scheme Procedure: make-mutex
Create a new mutex object.

Scheme Procedure: lock-mutex mutex
Lock mutex. If the mutex is already locked, the calling thread blocks until the mutex becomes available. The function returns when the calling thread owns the lock on mutex.

Scheme Procedure: unlock-mutex mutex
Unlocks mutex if the calling thread owns the lock on mutex. Calling unlock-mutex on a mutex not owned by the current thread results in undefined behaviour. Once a mutex has been unlocked, one thread blocked on mutex is awakened and grabs the mutex lock.

Scheme Procedure: make-condition-variable

Scheme Procedure: wait-condition-variable cond-var mutex

Scheme Procedure: signal-condition-variable cond-var

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003