Boost logo

Boost :

Subject: Re: [boost] [thread][thread_specific_ptr]
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-10-27 22:23:10


> boost::thread_specific_ptr acts as a pointer rather than a value.
> It will start out as a null pointer in each thread. You can test
> whether it has been set to something else with
>
> if(tls_3.get() != 0)
>
> In Christ,
> Steven Watanabe

I see. I have to give this class and its limitations some more thought.

For the time being, I see myself having to do that test before each usage of the globals.
ie.

    if ( tls_3.get() == NULL ) tls_3.reset( new int );
    *tls_3 = 999;

This kind of coding can get expensive if used constantly in that manner.
-Sid Sacek


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk