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


Benjamin Kosnik 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.

Regards
Martin


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