334 |
@deffn {Scheme Procedure} lock-mutex mutex |
@deffn {Scheme Procedure} lock-mutex mutex |
335 |
Lock @var{mutex}. If the mutex is already locked, the calling thread |
Lock @var{mutex}. If the mutex is already locked, the calling thread |
336 |
blocks until the mutex becomes available. The function returns when |
blocks until the mutex becomes available. The function returns when |
337 |
the calling thread owns the lock on @var{mutex}. |
the calling thread owns the lock on @var{mutex}. Locking a mutex that |
338 |
|
a thread already owns will succeed right away and will not block the |
339 |
|
thread. That is, Guile's mutexes are @emph{recursive}. |
340 |
|
@end deffn |
341 |
|
|
342 |
|
@deffn {Scheme Procedure} try-mutex mutex |
343 |
|
Try to lock @var{mutex}. If the mutex is already locked by someone |
344 |
|
else, return @code{#f}. Else lock the mutex and return @code{#t}. |
345 |
@end deffn |
@end deffn |
346 |
|
|
347 |
@c begin (texi-doc-string "guile" "unlock-mutex") |
@c begin (texi-doc-string "guile" "unlock-mutex") |
348 |
@deffn {Scheme Procedure} unlock-mutex mutex |
@deffn {Scheme Procedure} unlock-mutex mutex |
349 |
Unlocks @var{mutex} if the calling thread owns the lock on @var{mutex}. |
Unlocks @var{mutex} if the calling thread owns the lock on |
350 |
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 |
351 |
in undefined behaviour. Once a mutex has been unlocked, one thread |
thread results in undefined behaviour. Once a mutex has been unlocked, |
352 |
blocked on @var{mutex} is awakened and grabs the mutex lock. |
one thread blocked on @var{mutex} is awakened and grabs the mutex |
353 |
|
lock. Every call to @code{lock-mutex} by this thread must be matched |
354 |
|
with a call to @code{unlock-mutex}. Only the last call to |
355 |
|
@code{unlock-mutex} will actually unlock the mutex. |
356 |
@end deffn |
@end deffn |
357 |
|
|
358 |
@c begin (texi-doc-string "guile" "make-condition-variable") |
@c begin (texi-doc-string "guile" "make-condition-variable") |
360 |
@end deffn |
@end deffn |
361 |
|
|
362 |
@c begin (texi-doc-string "guile" "wait-condition-variable") |
@c begin (texi-doc-string "guile" "wait-condition-variable") |
363 |
@deffn {Scheme Procedure} wait-condition-variable cond-var mutex |
@deffn {Scheme Procedure} wait-condition-variable cond-var mutex [time] |
364 |
|
Wait until @var{cond-var} has been signalled. While waiting, |
365 |
|
@var{mutex} is atomically unlocked (as with @code{unlock-mutex}) and |
366 |
|
is locked again when this function returns. When @var{time} is given, |
367 |
|
it specifies a point in time where the waiting should be aborted. It |
368 |
|
can be either a integer as returned by @code{current-time} or a pair |
369 |
|
as returned by @code{gettimeofday}. When the waiting is aborted the |
370 |
|
mutex is locked and @code{#f} is returned. When the condition |
371 |
|
variable is in fact signalled, the mutex is also locked and @code{#t} |
372 |
|
is returned. |
373 |
@end deffn |
@end deffn |
374 |
|
|
375 |
@c begin (texi-doc-string "guile" "signal-condition-variable") |
@c begin (texi-doc-string "guile" "signal-condition-variable") |
376 |
@deffn {Scheme Procedure} signal-condition-variable cond-var |
@deffn {Scheme Procedure} signal-condition-variable cond-var |
377 |
@end deffn |
@end deffn |
378 |
|
|
379 |
|
@c begin (texi-doc-string "guile" "broadcast-condition-variable") |
380 |
|
@deffn {Scheme Procedure} signal-condition-variable cond-var |
381 |
|
@end deffn |
382 |
|
|
383 |
@node Higher level thread procedures |
@node Higher level thread procedures |
384 |
@subsection Higher level thread procedures |
@subsection Higher level thread procedures |