On Apr 24, 3:43 pm, "Chris Thomasson" comcast.net> wrote:
>
> There are benefits for using TLS. Think of a simple contrived scenario like:
>
> void function() {
> // I need to allocate from m_alloc...
> // How can I do this without adding any parameters?
>
> }
>
> void thread() {
> GenericAllocator m_alloc;
> function();
>
> }
>
> AFAICT, your allocator can use TLS as-is... Basically, something like:
>
> void function() {
> GenericAllocator* const pm_alloc = pthread_getspecific(...);
> // Now I can allocate from m_alloc! :^D
>
> }
>
> void thread() {
> GenericAllocator m_alloc;
> pthread_setspecific(..., &m_alloc);
> function();
>
> }
>
> Don't you think that your design could "possibly" benefit from using TLS?
> IMVHO, it would increase its flexibility...
>
You are right, TLS sounds better than a multi-threaded lock. I add TLS
support in my code now. See