1
Fork 0
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:
Taylan Ulrich Bayırlı/Kammer 2016-06-25 16:43:36 +02:00 committed by Andy Wingo
parent 3e719e0a35
commit d5d7e30348

View file

@ -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)