Subj : Re: C++ desired features To : comp.lang.c++.moderated,comp.programming.threads From : Hans Boehm Date : Sun Feb 27 2005 08:13 pm Sergey P. Derevyago wrote: > > Do destructors modify some shared data? Yes they do! > But what does the shared data mean in this context? That's the point! > > A destructor can issue a system call in order to free some > system-shared > resource. As the result, some system data structures will be > (asynchronously) > modified according to the request. The point is that it's the system > which is > obliged to protect the shared data. I.e. the destructor doesn't have to > lock > the access to this data so this data isn't considered as the shared > data from > the destructor's point of view. > I.e. we can definitely assume that the shared data in question is the > data > that must be protected by locks owned by the application. My claim is that a) Destructors almost always access shared data, which needs to be protected somehow. b) Especially in simple cases, this is often done in ways that are transparent to the application, and irrelevent to this discussion, as Sergey points out. c) This isn't always the case, and the more complex an application gets, the more likely it is that the destructor will operate on user shared data, typically because it operates on user-managed resources. d) It's not a good idea to rely on a programming style that doesn't allow me to replace a system-managed resource by a user-managed one, since that makes it significantly harder to later evolve the code. It may be that we actually agree here. I didn't quite understand the last sentence above. Hans [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] .