mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Fix 'monitor' macro.
* module/ice-9/threads.scm (monitor-mutex-table) (monitor-mutex-table-mutex, monitor-mutex-with-id): New variables. (monitor): Fix it.
This commit is contained in:
parent
3e719e0a35
commit
d5d7e30348
1 changed files with 18 additions and 3 deletions
|
@ -85,9 +85,24 @@
|
|||
(lambda () (begin e0 e1 ...))
|
||||
(lambda () (unlock-mutex x)))))
|
||||
|
||||
(define-syntax-rule (monitor first rest ...)
|
||||
(with-mutex (make-mutex)
|
||||
first rest ...))
|
||||
(define monitor-mutex-table (make-hash-table))
|
||||
|
||||
(define monitor-mutex-table-mutex (make-mutex))
|
||||
|
||||
(define (monitor-mutex-with-id id)
|
||||
(with-mutex monitor-mutex-table-mutex
|
||||
(or (hashq-ref monitor-mutex-table id)
|
||||
(let ((mutex (make-mutex)))
|
||||
(hashq-set! monitor-mutex-table id mutex)
|
||||
mutex))))
|
||||
|
||||
(define-syntax monitor
|
||||
(lambda (stx)
|
||||
(syntax-case stx ()
|
||||
((_ body body* ...)
|
||||
(let ((id (datum->syntax #'body (gensym))))
|
||||
#`(with-mutex (monitor-mutex-with-id '#,id)
|
||||
body body* ...))))))
|
||||
|
||||
(define (par-mapper mapper cons)
|
||||
(lambda (proc . lists)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue