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_specific
and pthread_set_specific
functions. Most threading libraries will encapsulate this though, and offer a C++ interface. In Boost, it is the thread_specific_ptr
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With