Subj : Re: Improving read-write lock To : comp.programming.threads From : Joe Seigh Date : Thu Feb 24 2005 10:16 am On Thu, 24 Feb 2005 15:00:29 +0100, Alexander Terekhov wrote: > > David Holmes wrote: >> Java monitor locks are automatically unlocked when an exception propagates >> out of a synchronized block or method. I think the C++ folk popularised this >> peculiar notion with RAII for locking. :( > > Brain-dead current semantics of exceptions specs aside for a moment, > C++ doesn't require unwinding for unexpected exceptions and sensible > implementations do not unwind; they just call terminate() at throw > point. So C++ RAII (for locking and other stuff) isn't that bad. It's > certainly better in this respect than brain-dead Java/C#'s "finally" > that "catch" everything. > Given that there seem to be an awful lot of programmers that think that locks should be unlocked on exceptions, I doubt sensible implementations are the rule. C++'s conflating unix asynchronous signals as synchronous exceptions exacerbates the problem. If you want to see what asynchronous execptions look like, take a look at the Java realtime extensions. They aren't pretty. But at least they don't let you pretend an asynchronous exception is the same as a synchronous one. -- Joe Seigh .