
Tonko Juricic wrote:
A stumbling block in my case is understanding how can your code be executed by a non-boost thread unless, at some level, you explicitly make it possible.
yes. A typical example is where you are writing application code (with boost::thread) that hooks up with a multi-threaded middleware (CORBA, say), i.e. your code provides callbacks that this third-party backend calls into.
So, if I didn't completely miss the point, TLS cleanup for non-boost threads is there to spare the programmer from having to analyze complex scenarious and calling sequences which may lead to a non-boost thread visiting the 'unsuspecting' method on your object.
Think about a logging library you are writing. For each log message you want to write out an id associated with the current thread. To do that you define a (global) thread_id variable, and you want that to have a different value for each executing thread. Thus, you provide a function 'get_thread_id()' that will allocate the variable on the thread-local heap the first time it is called (per thread, of course). But how is it cleaned up ? You get the idea... Stefan