proxygen
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor Class Reference

#include <ThreadLocal.h>

Classes

class  Iterator
 

Public Member Functions

 ~Accessor ()
 
Iterator begin () const
 
Iterator end () const
 
 Accessor (const Accessor &)=delete
 
Accessoroperator= (const Accessor &)=delete
 
 Accessor (Accessor &&other) noexcept
 
Accessoroperator= (Accessor &&other) noexcept
 
 Accessor ()
 

Private Member Functions

 Accessor (uint32_t id)
 
void release ()
 

Private Attributes

threadlocal_detail::StaticMetaBasemeta_
 
SharedMutexaccessAllThreadsLock_
 
std::mutexlock_
 
uint32_t id_
 

Friends

class ThreadLocalPtr< T, Tag, AccessMode >
 
class Iterator
 

Detailed Description

template<class T, class Tag = void, class AccessMode = void>
class folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor

Definition at line 247 of file ThreadLocal.h.

Constructor & Destructor Documentation

template<class T, class Tag = void, class AccessMode = void>
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::~Accessor ( )
inline

Definition at line 367 of file ThreadLocal.h.

367  {
368  release();
369  }
template<class T, class Tag = void, class AccessMode = void>
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::Accessor ( const Accessor )
delete
template<class T, class Tag = void, class AccessMode = void>
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::Accessor ( Accessor &&  other)
inlinenoexcept

Definition at line 382 of file ThreadLocal.h.

383  : meta_(other.meta_),
384  accessAllThreadsLock_(other.accessAllThreadsLock_),
385  lock_(other.lock_),
386  id_(other.id_) {
387  other.id_ = 0;
388  other.accessAllThreadsLock_ = nullptr;
389  other.lock_ = nullptr;
390  }
threadlocal_detail::StaticMetaBase & meta_
Definition: ThreadLocal.h:250
template<class T, class Tag = void, class AccessMode = void>
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::Accessor ( )
inline

Definition at line 407 of file ThreadLocal.h.

409  accessAllThreadsLock_(nullptr),
410  lock_(nullptr),
411  id_(0) {}
static StaticMeta< Tag, AccessMode > & instance()
threadlocal_detail::StaticMetaBase & meta_
Definition: ThreadLocal.h:250
template<class T, class Tag = void, class AccessMode = void>
folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::Accessor ( uint32_t  id)
inlineexplicitprivate

Member Function Documentation

template<class T, class Tag = void, class AccessMode = void>
Iterator folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::begin ( ) const
inline

Definition at line 371 of file ThreadLocal.h.

371  {
372  return ++Iterator(this);
373  }
template<class T, class Tag = void, class AccessMode = void>
Iterator folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::end ( ) const
inline

Definition at line 375 of file ThreadLocal.h.

References folly::ThreadLocal< T, Tag, AccessMode >::operator=().

375  {
376  return Iterator(this);
377  }
template<class T, class Tag = void, class AccessMode = void>
Accessor& folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::operator= ( const Accessor )
delete
template<class T, class Tag = void, class AccessMode = void>
Accessor& folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::operator= ( Accessor &&  other)
inlinenoexcept

Definition at line 392 of file ThreadLocal.h.

References folly::f14::swap(), and folly::swap().

392  {
393  // Each Tag has its own unique meta, and accessors with different Tags
394  // have different types. So either *this is empty, or this and other
395  // have the same tag. But if they have the same tag, they have the same
396  // meta (and lock), so they'd both hold the lock at the same time,
397  // which is impossible, which leaves only one possible scenario --
398  // *this is empty. Assert it.
399  assert(&meta_ == &other.meta_);
400  assert(lock_ == nullptr);
401  using std::swap;
402  swap(accessAllThreadsLock_, other.accessAllThreadsLock_);
403  swap(lock_, other.lock_);
404  swap(id_, other.id_);
405  }
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
threadlocal_detail::StaticMetaBase & meta_
Definition: ThreadLocal.h:250
template<class T, class Tag = void, class AccessMode = void>
void folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::release ( )
inlineprivate

Definition at line 423 of file ThreadLocal.h.

References folly::SharedMutexImpl< ReaderPriority, Tag_, Atom, BlockImmediately, AnnotateForThreadSanitizer >::unlock().

423  {
424  if (lock_) {
425  lock_->unlock();
426  DCHECK(accessAllThreadsLock_ != nullptr);
428  id_ = 0;
429  lock_ = nullptr;
430  accessAllThreadsLock_ = nullptr;
431  }
432  }

Friends And Related Function Documentation

template<class T, class Tag = void, class AccessMode = void>
friend class Iterator
friend

Definition at line 256 of file ThreadLocal.h.

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

Definition at line 248 of file ThreadLocal.h.

Member Data Documentation

template<class T, class Tag = void, class AccessMode = void>
SharedMutex* folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::accessAllThreadsLock_
private

Definition at line 251 of file ThreadLocal.h.

template<class T, class Tag = void, class AccessMode = void>
std::mutex* folly::ThreadLocalPtr< T, Tag, AccessMode >::Accessor::lock_
private

Definition at line 252 of file ThreadLocal.h.


The documentation for this class was generated from the following file: