On Fri, Nov 18, 2011 at 6:44 AM, Arun Ramasamy
class MyClass{ thread_specific_ptr<MyCacheType> cacheptr; public: MyClass(){
} function_that_deals_with_thspptr(){ cacheptr.reset(new MyCacheType());//alloc thread specific memory; //use the memory ......... cacheptr.reset(0);//dealloc thread specific memory; } };
No, actually it's more like this: function_that_deals_with_thspptr() { if( !cacheptr.get() ) { cacheptr.reset(new MyCacheType());//alloc thread specific memory; } //use *cacheptr ......... //there is no reset here }
Do you not know when the need for cacheptr ends?
No, because it should stick around to be reused until the MyClass object goes away or the thread it goes with goes away. Phillip