This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: more detailed io state; new_handler and thread safety


On Thu, Apr 04, 2002 at 01:47:27PM -0700, Martin Sebor wrote:
> > > 2.) I found no clear statement in my literature about
> > > the thread safety of std::set_new_handler but I suspect
> > > it is not thread safe. What is an approved way of having
> > > several threads with each having their own new_handler
> > > function set?
> 
> Unless the program replaces it, there's only one ::operator new() with
> the same memory pool per process, so it doesn't seem to make sense to
> have a per-thread new handler. With a replacement operator new, presumably
> one that manages a pool of memory for each thread, a program can create
> its own thread-safe set_new_handler function.
> 
> I think I do agree that there is a problem with the design of
> std::set_new_handler(): multiple threads may want to obtain the [address
> of the] current new handler, though, and that doesn't seem possible in
> a thread safe way.

Hmm, I've allways hoped to get around writing my own operator new ...

But thanx nevertheless, I have to think about that.

matthias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]