mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 04:30:19 +02:00
Updated mutex and condition varable functions.
This commit is contained in:
parent
e2d820a18c
commit
57c84ccd60
1 changed files with 28 additions and 6 deletions
|
@ -334,15 +334,25 @@ Create a new mutex object.
|
||||||
@deffn {Scheme Procedure} lock-mutex mutex
|
@deffn {Scheme Procedure} lock-mutex mutex
|
||||||
Lock @var{mutex}. If the mutex is already locked, the calling thread
|
Lock @var{mutex}. If the mutex is already locked, the calling thread
|
||||||
blocks until the mutex becomes available. The function returns when
|
blocks until the mutex becomes available. The function returns when
|
||||||
the calling thread owns the lock on @var{mutex}.
|
the calling thread owns the lock on @var{mutex}. Locking a mutex that
|
||||||
|
a thread already owns will succeed right away and will not block the
|
||||||
|
thread. That is, Guile's mutexes are @emph{recursive}.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
|
@deffn {Scheme Procedure} try-mutex mutex
|
||||||
|
Try to lock @var{mutex}. If the mutex is already locked by someone
|
||||||
|
else, return @code{#f}. Else lock the mutex and return @code{#t}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@c begin (texi-doc-string "guile" "unlock-mutex")
|
@c begin (texi-doc-string "guile" "unlock-mutex")
|
||||||
@deffn {Scheme Procedure} unlock-mutex mutex
|
@deffn {Scheme Procedure} unlock-mutex mutex
|
||||||
Unlocks @var{mutex} if the calling thread owns the lock on @var{mutex}.
|
Unlocks @var{mutex} if the calling thread owns the lock on
|
||||||
Calling unlock-mutex on a mutex not owned by the current thread results
|
@var{mutex}. Calling unlock-mutex on a mutex not owned by the current
|
||||||
in undefined behaviour. Once a mutex has been unlocked, one thread
|
thread results in undefined behaviour. Once a mutex has been unlocked,
|
||||||
blocked on @var{mutex} is awakened and grabs the mutex lock.
|
one thread blocked on @var{mutex} is awakened and grabs the mutex
|
||||||
|
lock. Every call to @code{lock-mutex} by this thread must be matched
|
||||||
|
with a call to @code{unlock-mutex}. Only the last call to
|
||||||
|
@code{unlock-mutex} will actually unlock the mutex.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@c begin (texi-doc-string "guile" "make-condition-variable")
|
@c begin (texi-doc-string "guile" "make-condition-variable")
|
||||||
|
@ -350,13 +360,25 @@ blocked on @var{mutex} is awakened and grabs the mutex lock.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@c begin (texi-doc-string "guile" "wait-condition-variable")
|
@c begin (texi-doc-string "guile" "wait-condition-variable")
|
||||||
@deffn {Scheme Procedure} wait-condition-variable cond-var mutex
|
@deffn {Scheme Procedure} wait-condition-variable cond-var mutex [time]
|
||||||
|
Wait until @var{cond-var} has been signalled. While waiting,
|
||||||
|
@var{mutex} is atomically unlocked (as with @code{unlock-mutex}) and
|
||||||
|
is locked again when this function returns. When @var{time} is given,
|
||||||
|
it specifies a point in time where the waiting should be aborted. It
|
||||||
|
can be either a integer as returned by @code{current-time} or a pair
|
||||||
|
as returned by @code{gettimeofday}. When the waiting is aborted the
|
||||||
|
mutex is locked and @code{#f} is returned. When the condition
|
||||||
|
variable is in fact signalled, the mutex is also locked and @code{#t}
|
||||||
|
is returned.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@c begin (texi-doc-string "guile" "signal-condition-variable")
|
@c begin (texi-doc-string "guile" "signal-condition-variable")
|
||||||
@deffn {Scheme Procedure} signal-condition-variable cond-var
|
@deffn {Scheme Procedure} signal-condition-variable cond-var
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@c begin (texi-doc-string "guile" "broadcast-condition-variable")
|
||||||
|
@deffn {Scheme Procedure} signal-condition-variable cond-var
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@node Higher level thread procedures
|
@node Higher level thread procedures
|
||||||
@subsection Higher level thread procedures
|
@subsection Higher level thread procedures
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue