[squeak-dev] Thread Safe Collections
Guillermo Adrián Molina
guille at losmolina.com.ar
Thu Apr 24 10:16:59 UTC 2008
Hi!
I would like to discuss an implementation of thread safe collections (and
streams, and others).
I can think on three possible approaches, the first one is to convert
every class to be thread safe, the other is to implement new thread safe
classes.
I think that the first approach is interesting because the user wouldn't
have to care about any thing to be thread safe. We would just use the
class that is guaranteed to be thread safe by the system. But there would
be an overhead imposed by the synchronization mechanism needed by a thread
safe implementation.
The second approach would let you choose between fast thread unsafe
collections, and a slower thread safe collections. But you would have to
choose it yourself. It would not be automatic.
This could be done by subclassing every collection class like this:
Object
+Collection
+ThreadSafeCollection
+Bag
|+ThreadSafeBag
+Set
+ThreadSafeSet
Or doing an entirely new hierarchy like this (with Traits to implement
similar behavior):
Object
+Collection
|+Bag
|+Set
+ThreadSafeCollection
+ThreadSafeBag
+ThreadSafeSet
What do you think?
Cheers
Guille
More information about the Squeak-dev
mailing list
|