Recently I have discovered the magic of boost thread specific pointers. After some research on thread safety I would like to know how exactly boost thread specific pointers work.However, I can't seem to find this in the documentation. Can anyone provide some insight on this or some detailed documentation?
From the Boost docs on thread local storage:
boost::thread_specific_ptr
provides a portable mechanism for thread-local storage that works on all compilers supported by Boost.Thread. Each instance ofboost::thread_specific_ptr
represents a pointer to an object (such aserrno
) where each thread must have a distinct value. The value for the current thread can be obtained using theget()
member function, or by using the * and -> pointer deference operators. Initially the pointer has a value of NULL in each thread, but the value for the current thread can be set using thereset()
member function.
And you can find the Boost source here.