Include the header "Dinkum/threads/tss" to define the
thread-specific storage
template thread_specific_ptr.
namespace Dinkum {
namespace threads {
class thread_specific_ptr;
} // namespace threads
} // namespace Dinkum
thread_specific_ptrget
· operator->
· operator*
· release
· reset
· thread_specific_ptr
· ~thread_specific_ptr
template <class T>
class thread_specific_ptr
{
public:
thread_specific_ptr();
~thread_specific_ptr();
T *get() const;
T *operator->() const;
T& operator*() const;
T *release();
void reset(T *ptr = 0);
// exposition only
private:
T *data;
// not implemented
thread_specific_ptr::thread_specific_ptr(const thread_specific_ptr&);
thread_specific_ptr<T>& thread_specific_ptr::operator= (const thread_specific_ptr<T>&);
};
The template class describes an object that controls
thread-specific storage for a
data object of type T.
The template holds a pointer data of type T*;
the stored value data can be different in different threads,
so threads can use different data objects,
accessed through the same thread_specific_ptr object.
Objects of class thread_specific_ptr<T> cannot be copied.
thread_specific_ptr::getT *get() const;
The member function returns the thread-specific stored value data.
thread_specific_ptr::operator->T *operator->() const;
Precondition:
get() != 0.
The member function returns the thread-specific stored value data.
thread_specific_ptr::operator*T& operator*() const;
Precondition:
get() != 0.
The member function returns *get().
thread_specific_ptr::releaseT *release();
The member function sets the thread-specific stored value data to 0
and returns the previous value of the stored value data.
thread_specific_ptr::resetvoid reset(T *ptr = 0);
The member function does nothing if the thread-specific stored value data
equals ptr; otherwise it
deletes the thread-specific stored value data and
sets the thread-specific stored value data to ptr.
thread_specific_ptr::thread_specific_ptrthread_specific_ptr();
The constructor constructs a thread_specific_ptr<T> object
with initial stored value data equal to 0 for all threads.
thread_specific_ptr::~thread_specific_ptr~thread_specific_ptr();
The destructor frees resources used by the object. It does not delete thread-specific data pointers.
See also the Table of Contents and the Index.
Copyright © 1992-2013 by Dinkumware, Ltd. Portions derived from work copyright © 2001 by William E. Kempf. All rights reserved.