manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.21.1 Arbiters

Arbiters are synchronization objects, they can be used by threads to control access to a shared resource. An arbiter can be locked to indicate a resource is in use, and unlocked when done.

An arbiter is like a light-weight mutex (see section Mutexes and Condition Variables). It uses less memory and may be faster, but there’s no way for a thread to block waiting on an arbiter, it can only test and get the status returned.

Scheme Procedure: make-arbiter name
C Function: scm_make_arbiter (name)

Return an object of type arbiter and name name. Its state is initially unlocked. Arbiters are a way to achieve process synchronization.

Scheme Procedure: try-arbiter arb
C Function: scm_try_arbiter (arb)

If arb is unlocked, then lock it and return #t. If arb is already locked, then do nothing and return #f.

Scheme Procedure: release-arbiter arb
C Function: scm_release_arbiter (arb)

If arb is locked, then unlock it and return #t. If arb is already unlocked, then do nothing and return #f.

Typical usage is for the thread which locked an arbiter to later release it, but that’s not required, any thread can release it.


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

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.