[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Thread safe hash tables?

From: Thomas Chust
Subject: Re: [Chicken-users] Thread safe hash tables?
Date: Sun, 5 Mar 2006 13:45:43 +0000 (GMT)

On Sun, 5 Mar 2006, Reed Sheridan wrote:

Why not just do something like:

(define (make-locking-hash-table)
 (cons (make-mutex) (make-hash-table)))

(define (locking-hash-table-set! lht . args)
     (lambda () (mutex-lock! (car lht)))
     (lambda () (apply hash-table-set! (cdr lht) args ))
     (lambda () ...unlock it)))

That seems better than using bazillions of dynamic-winds to me.


your approach is perfectly valid (although it results in the same amount of dynamic-wind blocks being processed as mine ;) but I prefer to make the scope of the locks explicit, because I do want to have more code than just the hash table access synchronized in some places.

Of course I don't spell out every dynamic-wind block. That's what macros are good for :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]