![]() |
Home | Libraries | People | FAQ | More |
// #include <boost/thread/tss.hpp> namespace boost { template <typename T> class thread_specific_ptr { public: thread_specific_ptr(); explicit thread_specific_ptr(void (*cleanup_function)(T*)); ~thread_specific_ptr(); T* get() const; T* operator->() const; T& operator*() const; T* release(); void reset(T* new_value=0); }; }
delete this->get()
is well-formed.
Construct a thread_specific_ptr
object for storing a pointer to an object of type T
specific to each thread. The default delete
-based
cleanup function will be used to destroy any thread-local objects
when reset()
is called, or the thread exits.
boost::thread_resource_error
if an error
occurs.
cleanup_function(this->get())
does not throw any exceptions.
Construct a thread_specific_ptr
object for storing a pointer to an object of type T
specific to each thread. The supplied cleanup_function
will be used to destroy any thread-local objects when reset()
is called, or the thread exits.
boost::thread_resource_error
if an error
occurs.
All the thread specific instances associated to this thread_specific_ptr (except maybe the one associated to this thread) must be null.
Calls this->reset()
to clean up the associated value for the current thread, and destroys
*this
.
Nothing.
The requirement is due to the fact that in order to delete all these instances, the implementation should be forced to maintain a list of all the threads having an associated specific ptr, which is against the goal of thread specific data.
![]() |
Note |
---|---|
Care needs to be taken to ensure that any threads still running after
an instance of |
The pointer associated with the current thread.
Nothing.
![]() |
Note |
---|---|
The initial value associated with an instance of |
this->get()
Nothing.
this->get
is not NULL
.
*(this->get())
Nothing.
If this->get()!=new_value
and this->get()
is non-NULL
,
invoke delete this->get()
or cleanup_function(this->get())
as appropriate. Store new_value
as the pointer associated
with the current thread.
this->get()==new_value
boost::thread_resource_error
if an error
occurs.
Return this->get()
and store NULL
as
the pointer associated with the current thread without invoking the
cleanup function.
this->get()==0
Nothing.