more detailed io state; new_handler and thread safety
Martin Sebor
sebor@roguewave.com
Thu Apr 4 12:46:00 GMT 2002
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
More information about the Libstdc++
mailing list