folly::ThreadLocalPtr

Thread-local owning pointer to a value of type T.

Synopsis

Declared in <folly/ThreadLocal.h>

template<
    class T,
    class Tag = void,
    class AccessMode = void>
class ThreadLocalPtr;

Description

Has semantics similar to boost::thread_specific_ptr: each thread sees an independent pointer, and the pointed-to object is deleted when the thread exits or the pointer is reset. Tag groups instances that share a pthread_key_t, and AccessMode selects the access mode for iterating all threads.

Types

NameDescription
Accessor Iterable view over the values held for all threads.

Member Functions

NameDescription
ThreadLocalPtr [constructor]Constructors
~ThreadLocalPtr [destructor]Destroys the pointer, deleting the values held for all threads.
operator= Move-assigns from other, destroying any values held by *this first.
accessAllThreads Returns an accessor that iterates the values held for all threads.
get Returns the calling thread's pointer.
operator* Accesses the calling thread's value.
operator-> Accesses the calling thread's value.
release Releases ownership of the calling thread's value without deleting it.
reset reset overloads
operator bool Tests whether the calling thread's value is set.