(define malloced-aliens-mutex)
(define (free-malloced-aliens)
- (with-thread-mutex-lock malloced-aliens-mutex
- (lambda ()
- (let loop ((aliens malloced-aliens)
- (prev #f))
- (if (pair? aliens)
- (if (weak-pair/car? (car aliens))
- (loop (cdr aliens) aliens)
- (let ((copy (weak-cdr (car aliens)))
- (next (cdr aliens)))
- (if prev
- (set-cdr! prev next)
- (set! malloced-aliens next))
- (if (not (alien-null? copy))
- (begin
- ((ucode-primitive c-free 1) copy)
- (alien-null! copy)))
- (loop next prev))))))))
+ (with-thread-mutex-try-lock
+ malloced-aliens-mutex
+ (lambda ()
+ (let loop ((aliens malloced-aliens)
+ (prev #f))
+ (if (pair? aliens)
+ (if (weak-pair/car? (car aliens))
+ (loop (cdr aliens) aliens)
+ (let ((copy (weak-cdr (car aliens)))
+ (next (cdr aliens)))
+ (if prev
+ (set-cdr! prev next)
+ (set! malloced-aliens next))
+ (if (not (alien-null? copy))
+ (begin
+ ((ucode-primitive c-free 1) copy)
+ (alien-null! copy)))
+ (loop next prev))))))
+ (lambda ()
+ unspecific)))
(define (reset-malloced-aliens!)
(set! malloced-aliens-mutex (make-thread-mutex))