Boost logo

Boost Users :

Subject: [Boost-users] [boost][thread] thread_local vs boost::thread_specific vs ::pthread_key_t
From: chilabot_at_[hidden]
Date: 2015-04-16 11:07:26


I have a program that dlopens some libraries (all C++),
that use TLS for a variable (which passed to all libraries).
With the keyword 'thread_local' and with 'boost::thread_specific',
the storage of the variable is different for every thread AND
for every shared library. With 'pthread_key_t' it's only different
for every thread, it behaves as expected. I guess
'boost::thread_specific' uses 'thread_local' and that's why
it behaves like it. Why does 'thread_local' behave like this?

$ clang --version
Ubuntu clang version 3.5.0-4ubuntu2~trusty2
(tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix

$ uname -a
Linux robert-y510p 3.13.0-49-generic #81-Ubuntu SMP Tue
Mar 24 19:29:48 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

ref
http://stackoverflow.com/questions/29656089/
thread-local-vs-boostthread-specific-vs-pthread-key-t


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net