Cleanup for thread local storage?

Kevin P. Fleming kpfleming@digium.com
Tue May 6 20:41:00 GMT 2008


Stephen Spackman wrote:

> It's important because one of the things that TLS is nice for is
> optimizations like per-thread task queues and free lists, but a
> *reliable* mechanism is needed to release their contents on thread exit,
> and it really *should* be bound to the variable declaration point
> itself, or many of the benefits of TLS are lost.

We use thread-local-storage quite a bit in Asterisk, but we (for the
reasons you mention) don't use GCC's version of it, we use the direct
pthread library calls for allocating and freeing TLS keys. These keys
have destructor callbacks, so we have complete control over the TLS
object lifetimes.

-- 
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)



More information about the Gcc-help mailing list