Re: thread_local compatible with other threading models?

2017-11-15 Thread Todd Lipcon
We use __thread pretty extensively in Kudu and it works fine. That said, we
make sure that all of our __thread variables are PODs or pointers, and in
the case that we want to actually run a destructor on thread-exit, we use
our own wrappers in kudu/util/thread_local.h which take care of registering
the destructor calls onto a thread-local linked list and invoking them all
on exit (making use of pthreads APIs to do so).

-Todd

On Wed, Nov 15, 2017 at 10:06 AM, Tim Armstrong 
wrote:

> Pretty sure that boost::thread uses pthreads under the covers, so I think
> the question is whether thread_local works with the lowest common
> denoninator pthreads.
>
> It sounds like thread_local uses an older mechanism __thread under the
> covers that
> https://sourceware.org/glibc/wiki/Destructor%20support%
> 20for%20thread_local%20variables
> but that there is some special handling for destructors. My guess is that
> that will work with pthreads but we could check experimentally.
>
> On Tue, Nov 14, 2017 at 9:21 AM, Jim Apple  wrote:
>
> > A quick git grep shows use of both boost::thread and pthread. C++14 has a
> > thread_local keyword:
> >
> > http://eel.is/c++draft/basic.stc.thread
> >
> > Do we know if the semantics of thread_local in C++14 are compatible with
> > thread-locality in pthreads and boost::thread?
> >
>



-- 
Todd Lipcon
Software Engineer, Cloudera


Re: thread_local compatible with other threading models?

2017-11-15 Thread Tim Armstrong
Pretty sure that boost::thread uses pthreads under the covers, so I think
the question is whether thread_local works with the lowest common
denoninator pthreads.

It sounds like thread_local uses an older mechanism __thread under the
covers that
https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
but that there is some special handling for destructors. My guess is that
that will work with pthreads but we could check experimentally.

On Tue, Nov 14, 2017 at 9:21 AM, Jim Apple  wrote:

> A quick git grep shows use of both boost::thread and pthread. C++14 has a
> thread_local keyword:
>
> http://eel.is/c++draft/basic.stc.thread
>
> Do we know if the semantics of thread_local in C++14 are compatible with
> thread-locality in pthreads and boost::thread?
>


thread_local compatible with other threading models?

2017-11-14 Thread Jim Apple
A quick git grep shows use of both boost::thread and pthread. C++14 has a
thread_local keyword:

http://eel.is/c++draft/basic.stc.thread

Do we know if the semantics of thread_local in C++14 are compatible with
thread-locality in pthreads and boost::thread?