44 #include <type_traits> 55 template <
class T,
class Tag,
class AccessMode>
58 template <
class T,
class Tag =
void,
class AccessMode =
void>
88 return tlp_.accessAllThreads();
136 template <
class T,
class Tag =
void,
class AccessMode =
void>
147 assert(
this != &other);
159 return static_cast<T*
>(w.
ptr);
173 return static_cast<T*
>(w.
release());
189 explicit operator bool()
const {
190 return get() !=
nullptr;
199 typename =
typename std::enable_if<
201 void reset(std::unique_ptr<SourceT, Deleter> source) {
202 auto deleter = [delegate = source.get_deleter()](
204 reset(source.release(), deleter);
213 typename =
typename std::enable_if<
215 void reset(std::unique_ptr<SourceT> source) {
216 reset(source.release());
227 template <
class Deleter>
228 void reset(
T* newPtr,
const Deleter& deleter) {
241 w->set(newPtr, deleter);
276 return *
static_cast<T*
>(
281 return *
static_cast<T*
>(
290 : accessor_(accessor),
291 e_(&accessor_->meta_.head_.elements[accessor_->id_].node) {}
383 : meta_(other.meta_),
384 accessAllThreadsLock_(other.accessAllThreadsLock_),
388 other.accessAllThreadsLock_ =
nullptr;
389 other.lock_ =
nullptr;
399 assert(&meta_ == &other.meta_);
400 assert(lock_ ==
nullptr);
402 swap(accessAllThreadsLock_, other.accessAllThreadsLock_);
403 swap(lock_, other.lock_);
404 swap(id_, other.id_);
408 : meta_(threadlocal_detail::StaticMeta<
Tag, AccessMode>::instance()),
409 accessAllThreadsLock_(
nullptr),
415 : meta_(threadlocal_detail::StaticMeta<
Tag, AccessMode>::instance()),
416 accessAllThreadsLock_(&meta_.accessAllThreadsLock_),
417 lock_(&meta_.lock_) {
418 accessAllThreadsLock_->
lock();
426 DCHECK(accessAllThreadsLock_ !=
nullptr);
427 accessAllThreadsLock_->
unlock();
430 accessAllThreadsLock_ =
nullptr;
440 "Must use a unique Tag to use the accessAllThreads feature");
441 return Accessor(id_.getOrAllocate(StaticMeta::instance()));
446 StaticMeta::instance().destroy(&id_);
456 namespace threadlocal_detail {
460 template <
typename T,
typename Tag,
typename AccessMode>
465 template <
typename T,
typename Tag,
typename AccessMode>
FOLLY_ALWAYS_INLINE ThreadEntry * getThreadEntry()
std::function< T *()> constructor_
bool operator==(Iterator const &rhs) const
void reset(T *newPtr=nullptr)
void reset(T *newPtr=nullptr)
#define FOLLY_ALWAYS_INLINE
T const & operator*() const
FOLLY_NOINLINE T * makeTlp() const
ThreadLocal & operator=(ThreadLocal &&)=default
Accessor accessAllThreads() const
Iterator & operator--(int)
bool operator!=(Iterator const &rhs) const
constexpr detail::Map< Move > move
Accessor(Accessor &&other) noexcept
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
ThreadLocalPtr< T, Tag, AccessMode > tlp_
FOLLY_PUSH_WARNING RHS rhs
ThreadLocalPtr & operator=(ThreadLocalPtr &&other)
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
std::bidirectional_iterator_tag iterator_category
GuardImpl guard(ErrorHandler &&handler)
bool equal(const Iterator &other) const
Accessor & operator=(Accessor &&other) noexcept
void reset(T *newPtr, const Deleter &deleter)
Accessor accessAllThreads() const
static const char *const value
FOLLY_ALWAYS_INLINE ThreadEntryNode * getNext()
T const * operator->() const
const T & dereference() const
const Accessor * accessor_
void swap(exception_wrapper &a, exception_wrapper &b) noexcept
FOLLY_NODISCARD detail::ScopeGuardImplDecay< F, true > makeGuard(F &&f) noexcept(noexcept(detail::ScopeGuardImplDecay< F, true >(static_cast< F && >(f))))
void reset(std::unique_ptr< SourceT > source)
void reset(std::unique_ptr< SourceT, Deleter > source)
ThreadLocal(F &&constructor)
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Iterator(const Accessor *accessor)
ThreadLocalPtr(ThreadLocalPtr &&other) noexcept
SharedMutex * accessAllThreadsLock_
#define FOLLY_ATTR_VISIBILITY_HIDDEN
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
threadlocal_detail::ThreadEntryNode * e_
ThreadLocalPtr< T, Tag, AccessMode >::Accessor Accessor
FOLLY_ALWAYS_INLINE ThreadEntryNode * getPrev()
threadlocal_detail::StaticMetaBase & meta_
Iterator & operator++(int)
ElementWrapper * elements
constexpr ThreadLocalPtr()
threadlocal_detail::StaticMeta< Tag, AccessMode > StaticMeta
constexpr detail::Dereference dereference