Farid Zaripov-2 wrote:
> I wonder if it would be worthwhile to give users the ability to
> decide whether to enable TLS in case they don't need LoadLibrary()
> or not. What do you think?
Hmm. I only can say, that nor MSVC run-time, nor STLport nor boost libraries are not
using the implicit TLS.
Currently the TLS variables are used in 3 places only:
- exception's what-buffer;
- table for random number generator;
- buffer for __rw_tmpbuf().
Right. But there might be other opportunities for TLS (e.g., in locale or
maybe in some of the C++ 0x facilities?)
We need to check what would be if an exception object is created in one thread (i.e. thus "throw new exception();")
and after catch() the pointer passed to another thread and there deleted?
Ouch! Tricky! I hadn't thought of this when I implemented it. I think we
either need to get this case to work or disable TLS for exceptions, but
we can't have it crash (which, I assume, is what happens in this case?)
The same issue with __rw_tmpbuf(). What would be if we getting the temporary buffer in one thread using
get_temporary_buffer(), and releasing it, using return_temporary_buffer(), in another thread?
That would also be a problem. In this case, though, I think it would
be sufficient to document it as a restriction of the API. IMO, getting
this to work would be more trouble than it's worth.
Martin