mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
remove mutex in make-object-property
* module/ice-9/boot-9.scm (make-object-property): Remove the mutex; weak tables are now threadsafe.
This commit is contained in:
parent
a141db8604
commit
633f3a18b7
1 changed files with 4 additions and 8 deletions
|
@ -886,15 +886,11 @@ VALUE."
|
|||
;; properties within the object itself.
|
||||
|
||||
(define (make-object-property)
|
||||
(define-syntax-rule (with-mutex lock exp)
|
||||
(dynamic-wind (lambda () (lock-mutex lock))
|
||||
(lambda () exp)
|
||||
(lambda () (unlock-mutex lock))))
|
||||
(let ((prop (make-weak-key-hash-table))
|
||||
(lock (make-mutex)))
|
||||
;; Weak tables are thread-safe.
|
||||
(let ((prop (make-weak-key-hash-table)))
|
||||
(make-procedure-with-setter
|
||||
(lambda (obj) (with-mutex lock (hashq-ref prop obj)))
|
||||
(lambda (obj val) (with-mutex lock (hashq-set! prop obj val))))))
|
||||
(lambda (obj) (hashq-ref prop obj))
|
||||
(lambda (obj val) (hashq-set! prop obj val)))))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue