diff options
Diffstat (limited to 'module/srfi/srfi-18.scm')
-rw-r--r-- | module/srfi/srfi-18.scm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/module/srfi/srfi-18.scm b/module/srfi/srfi-18.scm index 79aedb8d1..d4aac8ef7 100644 --- a/module/srfi/srfi-18.scm +++ b/module/srfi/srfi-18.scm @@ -1,6 +1,6 @@ ;;; srfi-18.scm --- Multithreading support -;; Copyright (C) 2008, 2009, 2010, 2012, 2014, 2018 Free Software Foundation, Inc. +;; Copyright (C) 2008, 2009, 2010, 2012, 2014, 2018, 2025, 2025 Free Software Foundation, Inc. ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -34,6 +34,7 @@ #:use-module (ice-9 exceptions) #:use-module ((ice-9 threads) #:prefix threads:) #:use-module (ice-9 match) + #:use-module (ice-9 weak-tables) #:use-module (srfi srfi-9) #:export (;; Threads make-thread @@ -183,10 +184,11 @@ object (absolute point in time), or #f." (thunk))) (lambda () (let ((thread (current-thread))) - (hash-for-each (lambda (mutex _) - (when (eq? (mutex-owner mutex) thread) - (abandon-mutex! mutex))) - mutexes)))))) + (weak-key-hash-table-for-each + (lambda (mutex _) + (when (eq? (mutex-owner mutex) thread) + (abandon-mutex! mutex))) + mutexes)))))) (define* (make-thread thunk #:optional name) (let* ((sm (make-mutex 'start-mutex)) @@ -290,7 +292,7 @@ object (absolute point in time), or #f." (define* (mutex-lock! mutex #:optional timeout (thread (current-thread))) (let ((mutexes (thread-mutexes))) (when mutexes - (hashq-set! mutexes mutex #t))) + (weak-key-hash-table-set! mutexes mutex #t))) (cond ((threads:lock-mutex (mutex-prim mutex) (timeout->absolute-time timeout)) |