- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: Synchronized*
Tue, 2009-05-26, 22:37
>>>>> "David" == David MacIver writes:
David> Hi, I was talking to paul about this in #scala and basically
David> came to the conclusion that SynchronizedMap, SynchronizedBuffer,
David> etc. are actually a terrible idea. I would like to advocate
David> their removal in 2.8 (or at least their extreme deprecation
+1
David> synchronizing all the methods is not a good way to add thread
David> safety to a class anyway. If this is the best one can do for a
David> class then it's uniformly better to declare it to not be
David> threadsafe and manage synchronization externally.
+1,000,000
Sat, 2009-05-30, 12:27
#2
Re: Synchronized*
I think SynchronizedMaps are very useful form a client perspective. I
needed them myself in the Scala Eclipse IDE. Workarounds from clients
are probably worse than the functionality provided by SynchronizedMap.
Sure, you have to be careful when extending the collection classes,
and also when creating your own maps. But these are the rare cases.
The most common case is that you want to take a standard map
implementation off the shelf and make it synchronized.
So, for all their shortcomings I believe that SynchronizedMap/Set are
essential ingredients of a collection library.
Cheers
Sat, 2009-05-30, 12:37
#3
Re: Synchronized*
I should mention that the problems with SynchronizedMap could also be
interpreyted as a shortcoming of the language. What you want is a
form of quantification, that you can mixin a feature to all methods of
a class or trait automatically, or by a wildcard. AOP can do that, of
course, but it comes with lots of other features entangled with it.
Cheers
On May 26, 2009, at 11:37 PM, Seth Tisue wrote:
> David> synchronizing all the methods is not a good way to add thread
> David> safety to a class anyway. If this is the best one can do for a
> David> class then it's uniformly better to declare it to not be
> David> threadsafe and manage synchronization externally.
>
> +1,000,000
But isn't this exactly what they do?
iulian
>