proxygen
folly::threadlocal_detail::StaticMetaBase::EntryID Class Reference

#include <ThreadLocalDetail.h>

Public Member Functions

constexpr EntryID ()
 
 EntryID (EntryID &&other) noexcept
 
EntryIDoperator= (EntryID &&other)
 
 EntryID (const EntryID &other)=delete
 
EntryIDoperator= (const EntryID &other)=delete
 
uint32_t getOrInvalid ()
 
uint32_t getOrAllocate (StaticMetaBase &meta)
 

Public Attributes

std::atomic< uint32_tvalue
 

Detailed Description

Definition at line 304 of file ThreadLocalDetail.h.

Constructor & Destructor Documentation

constexpr folly::threadlocal_detail::StaticMetaBase::EntryID::EntryID ( )
inline

Definition at line 308 of file ThreadLocalDetail.h.

folly::threadlocal_detail::StaticMetaBase::EntryID::EntryID ( EntryID &&  other)
inlinenoexcept

Definition at line 310 of file ThreadLocalDetail.h.

References folly::threadlocal_detail::kEntryIDInvalid.

310  : value(other.value.load()) {
311  other.value = kEntryIDInvalid;
312  }
constexpr uint32_t kEntryIDInvalid
folly::threadlocal_detail::StaticMetaBase::EntryID::EntryID ( const EntryID other)
delete

Member Function Documentation

uint32_t folly::threadlocal_detail::StaticMetaBase::EntryID::getOrAllocate ( StaticMetaBase meta)
inline

Definition at line 332 of file ThreadLocalDetail.h.

References folly::threadlocal_detail::StaticMetaBase::allocate(), and uint32_t.

332  {
333  uint32_t id = getOrInvalid();
334  if (id != kEntryIDInvalid) {
335  return id;
336  }
337  // The lock inside allocate ensures that a single value is allocated
338  return meta.allocate(this);
339  }
constexpr uint32_t kEntryIDInvalid
uint32_t folly::threadlocal_detail::StaticMetaBase::EntryID::getOrInvalid ( )
inline

Definition at line 324 of file ThreadLocalDetail.h.

Referenced by folly::threadlocal_detail::StaticMeta< Tag, AccessMode >::getSlowReserveAndCache().

324  {
325  // It's OK for this to be relaxed, even though we're effectively doing
326  // double checked locking in using this value. We only care about the
327  // uniqueness of IDs, getOrAllocate does not modify any other memory
328  // this thread will use.
329  return value.load(std::memory_order_relaxed);
330  }
EntryID& folly::threadlocal_detail::StaticMetaBase::EntryID::operator= ( EntryID &&  other)
inline

Definition at line 314 of file ThreadLocalDetail.h.

References folly::threadlocal_detail::kEntryIDInvalid.

314  {
315  assert(this != &other);
316  value = other.value.load();
317  other.value = kEntryIDInvalid;
318  return *this;
319  }
constexpr uint32_t kEntryIDInvalid
EntryID& folly::threadlocal_detail::StaticMetaBase::EntryID::operator= ( const EntryID other)
delete

Member Data Documentation

std::atomic<uint32_t> folly::threadlocal_detail::StaticMetaBase::EntryID::value

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