Do anyone know the best way to implement ThreadLocal in C++ whereby we can set and get values passed when neccesary.
I was reading about ThreaLocal in wikipedia and it says;
C++0x introduces the thread_local keyword. Aside that, various C++
compiler implementations provide specific ways to declare thread-local
variables:
Do anyone know the gcc declaration for this and perhaps its usage?
This is usually a part of whatever the threading library that your OS uses. In Linux, thread local storage is handled with
pthread_key_create,pthread_get_specificandpthread_set_specificfunctions. Most threading libraries will encapsulate this though, and offer a C++ interface. In Boost, it is thethread_specific_ptr…