proxygen
folly::hazptr_local< M, Atom > Class Template Reference

#include <Hazptr-fwd.h>

Public Member Functions

FOLLY_ALWAYS_INLINE hazptr_local ()
 
 hazptr_local (const hazptr_local &)=delete
 
hazptr_localoperator= (const hazptr_local &)=delete
 
 hazptr_local (hazptr_local &&)=delete
 
hazptr_localoperator= (hazptr_local &&)=delete
 
FOLLY_ALWAYS_INLINE ~hazptr_local ()
 
FOLLY_ALWAYS_INLINE hazptr_holder< Atom > & operator[] (uint8_t i) noexcept
 

Private Attributes

aligned_hazptr_holder< Atomraw_ [M]
 

Detailed Description

template<uint8_t M, template< typename > class Atom>
class folly::hazptr_local< M, Atom >

hazptr_local

hazptr_local

Optimized for construction and destruction of one or more hazptr_holder-s with local scope.

WARNING 1: Do not move from or to individual hazptr_holder-s.

WARNING 2: There can only be one hazptr_local active for the same thread at any time. This is not tracked and checked by the implementation (except in debug mode) because it would negate the performance gains of this class.

Definition at line 167 of file Hazptr-fwd.h.

Constructor & Destructor Documentation

template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE folly::hazptr_local< M, Atom >::hazptr_local ( )
inline

Constructor

Definition at line 342 of file HazptrHolder.h.

References count, h, folly::hazptr_holder< Atom >::hprec(), i, folly::kIsDebug, M, folly::hazptr_holder< Atom >::operator=(), tc, uint8_t, and UNLIKELY.

342  {
343  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
344 #if FOLLY_HAZPTR_THR_LOCAL
345  static_assert(
346  M <= hazptr_tc<Atom>::capacity(),
347  "M must be <= hazptr_tc::capacity().");
348  auto& tc = hazptr_tc_tls<Atom>();
349  auto count = tc.count();
350  if (UNLIKELY(M > count)) {
351  tc.fill(M - count);
352  }
353  if (kIsDebug) {
354  DCHECK(!tc.local());
355  tc.set_local(true);
356  }
357  for (uint8_t i = 0; i < M; ++i) {
358  auto hprec = tc[i].get();
359  DCHECK(hprec != nullptr);
360  new (&h[i]) hazptr_holder<Atom>(nullptr);
361  h[i].set_hprec(hprec);
362  }
363 #else
364  for (uint8_t i = 0; i < M; ++i) {
365  new (&h[i]) hazptr_holder<Atom>;
366  }
367 #endif
368  }
*than *hazptr_holder h
Definition: Hazptr.h:116
constexpr auto kIsDebug
Definition: Portability.h:264
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:336
static bool tc
**Optimized Holders **The template hazptr_array< M > provides most of the functionality *of M hazptr_holder s but with faster construction destruction *for M
Definition: Hazptr.h:104
int * count
#define UNLIKELY(x)
Definition: Likely.h:48
template<uint8_t M, template< typename > class Atom>
folly::hazptr_local< M, Atom >::hazptr_local ( const hazptr_local< M, Atom > &  )
delete
template<uint8_t M, template< typename > class Atom>
folly::hazptr_local< M, Atom >::hazptr_local ( hazptr_local< M, Atom > &&  )
delete
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE folly::hazptr_local< M, Atom >::~hazptr_local ( )
inline

Destructor

Definition at line 376 of file HazptrHolder.h.

References h, i, folly::kIsDebug, M, tc, and uint8_t.

376  {
377  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
378 #if FOLLY_HAZPTR_THR_LOCAL
379  if (kIsDebug) {
380  auto& tc = hazptr_tc_tls<Atom>();
381  DCHECK(tc.local());
382  tc.set_local(false);
383  }
384  for (uint8_t i = 0; i < M; ++i) {
385  h[i].reset();
386  }
387 #else
388  for (uint8_t i = 0; i < M; ++i) {
389  h[i].~hazptr_holder();
390  }
391 #endif
392  }
*than *hazptr_holder h
Definition: Hazptr.h:116
constexpr auto kIsDebug
Definition: Portability.h:264
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:336
static bool tc
**Optimized Holders **The template hazptr_array< M > provides most of the functionality *of M hazptr_holder s but with faster construction destruction *for M
Definition: Hazptr.h:104

Member Function Documentation

template<uint8_t M, template< typename > class Atom>
hazptr_local& folly::hazptr_local< M, Atom >::operator= ( const hazptr_local< M, Atom > &  )
delete
template<uint8_t M, template< typename > class Atom>
hazptr_local& folly::hazptr_local< M, Atom >::operator= ( hazptr_local< M, Atom > &&  )
delete
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE hazptr_holder<Atom>& folly::hazptr_local< M, Atom >::operator[] ( uint8_t  i)
inlinenoexcept

[] operator

Definition at line 395 of file HazptrHolder.h.

References h, i, and M.

395  {
396  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
397  DCHECK(i < M);
398  return h[i];
399  }
*than *hazptr_holder h
Definition: Hazptr.h:116
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:336
**Optimized Holders **The template hazptr_array< M > provides most of the functionality *of M hazptr_holder s but with faster construction destruction *for M
Definition: Hazptr.h:104

Member Data Documentation

template<uint8_t M, template< typename > class Atom>
aligned_hazptr_holder<Atom> folly::hazptr_local< M, Atom >::raw_[M]
private

Definition at line 336 of file HazptrHolder.h.


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