6b7 Subj : Re: C++ desired features To : comp.lang.c++.moderated,comp.programming.threads From : Hans Boehm Date : Thu Feb 24 2005 08:14 pm Sergey P. Derevyago wrote: > Hans Boehm wrote: > > If that's possible, great. For the problems I've dealt with, the > > problems usually aren't quite independent. And destructors especially > > tend to involve shared data structures, since their job is typically to > > return something to a shared resource pool. You can sometimes keep the > > resource pools per thread, but that incurs other substantial risks. > > > Well, what "shared data structures" you're talking about? What do typical destructors do? They might deallocate memory, which (inside the allocator implementation) involves updating a list of available memory. That's normally shared across threads, so that memory deallocated by one can be used by another. They might close file descriptors. That updates shared data structures in the IO library and the kernel to flush buffers, etc. A synchronous destructor might close a window, which would update a shared display of some kind. In the more interesting cases, it's likely to return some user-defined resource to a user-maintained pool. If you want to allow reuse of a resource from one thread in another, that involves a shared user-defined data structure containing available instances of that resource. I find it hard to come up with a destructor that is useful and does not access any shared data. (Of course the shared data might be in the kernel.) Hans [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] . 0