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

#include <Hazptr-fwd.h>

Public Member Functions

FOLLY_ALWAYS_INLINE hazptr_array ()
 
FOLLY_ALWAYS_INLINE hazptr_array (std::nullptr_t) noexcept
 
FOLLY_ALWAYS_INLINE hazptr_array (hazptr_array &&other) noexcept
 
 hazptr_array (const hazptr_array &)=delete
 
hazptr_arrayoperator= (const hazptr_array &)=delete
 
FOLLY_ALWAYS_INLINE ~hazptr_array ()
 
FOLLY_ALWAYS_INLINE hazptr_arrayoperator= (hazptr_array &&other) noexcept
 
FOLLY_ALWAYS_INLINE hazptr_holder< Atom > & operator[] (uint8_t i) noexcept
 

Private Attributes

aligned_hazptr_holder< Atomraw_ [M]
 
bool empty_ {false}
 

Detailed Description

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

hazptr_array

hazptr_array

Optimized template for bulk construction and destruction of hazard pointers.

WARNING: Do not move from or to individual hazptr_holder-s. Only move the whole hazptr_array.

NOTE: It is allowed to swap an individual hazptr_holder that belongs to hazptr_array with (a) a hazptr_holder object, or (b) a hazptr_holder that is part of hazptr_array, under the conditions: (i) both hazptr_holder-s are either both empty or both nonempty and (ii) both belong to the same domain.

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

Constructor & Destructor Documentation

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

Constructor

Definition at line 225 of file HazptrHolder.h.

225  {
226  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
227 #if FOLLY_HAZPTR_THR_LOCAL
228  static_assert(
229  M <= hazptr_tc<Atom>::capacity(),
230  "M must be within the thread cache capacity.");
231  auto& tc = hazptr_tc_tls<Atom>();
232  auto count = tc.count();
233  if (UNLIKELY(M > count)) {
234  tc.fill(M - count);
235  count = M;
236  }
237  uint8_t offset = count - M;
238  for (uint8_t i = 0; i < M; ++i) {
239  auto hprec = tc[offset + i].get();
240  DCHECK(hprec != nullptr);
241  new (&h[i]) hazptr_holder<Atom>(nullptr);
242  h[i].set_hprec(hprec);
243  }
244  tc.set_count(offset);
245 #else
246  for (uint8_t i = 0; i < M; ++i) {
247  new (&h[i]) hazptr_holder<Atom>;
248  }
249 #endif
250  }
*than *hazptr_holder h
Definition: Hazptr.h:116
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
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_ALWAYS_INLINE folly::hazptr_array< M, Atom >::hazptr_array ( std::nullptr_t  )
inlinenoexcept

Empty constructor

Definition at line 253 of file HazptrHolder.h.

253  {
254  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
255  for (uint8_t i = 0; i < M; ++i) {
256  new (&h[i]) hazptr_holder<Atom>(nullptr);
257  }
258  empty_ = true;
259  }
*than *hazptr_holder h
Definition: Hazptr.h:116
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
**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
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE folly::hazptr_array< M, Atom >::hazptr_array ( hazptr_array< M, Atom > &&  other)
inlinenoexcept

Move constructor

Definition at line 262 of file HazptrHolder.h.

262  {
263  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
264  auto hother = reinterpret_cast<hazptr_holder<Atom>*>(&other.raw_);
265  for (uint8_t i = 0; i < M; ++i) {
266  new (&h[i]) hazptr_holder<Atom>(std::move(hother[i]));
267  }
268  empty_ = other.empty_;
269  other.empty_ = true;
270  }
*than *hazptr_holder h
Definition: Hazptr.h:116
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
**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
template<uint8_t M, template< typename > class Atom>
folly::hazptr_array< M, Atom >::hazptr_array ( const hazptr_array< M, Atom > &  )
delete
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE folly::hazptr_array< M, Atom >::~hazptr_array ( )
inline

Destructor

Definition at line 276 of file HazptrHolder.h.

276  {
277  if (empty_) {
278  return;
279  }
280  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
281 #if FOLLY_HAZPTR_THR_LOCAL
282  auto& tc = hazptr_tc_tls<Atom>();
283  auto count = tc.count();
284  auto cap = hazptr_tc<Atom>::capacity();
285  if (UNLIKELY((M + count) > cap)) {
286  tc.evict((M + count) - cap);
287  count = cap - M;
288  }
289  for (uint8_t i = 0; i < M; ++i) {
290  h[i].reset();
291  tc[count + i].fill(h[i].hprec());
292  new (&h[i]) hazptr_holder<Atom>(nullptr);
293  }
294  tc.set_count(count + M);
295 #else
296  for (uint8_t i = 0; i < M; ++i) {
297  h[i].~hazptr_holder();
298  }
299 #endif
300  }
*than *hazptr_holder h
Definition: Hazptr.h:116
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
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

Member Function Documentation

template<uint8_t M, template< typename > class Atom>
hazptr_array& folly::hazptr_array< M, Atom >::operator= ( const hazptr_array< M, Atom > &  )
delete
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE hazptr_array& folly::hazptr_array< M, Atom >::operator= ( hazptr_array< M, Atom > &&  other)
inlinenoexcept

Move operator

Definition at line 303 of file HazptrHolder.h.

303  {
304  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
305  for (uint8_t i = 0; i < M; ++i) {
306  h[i] = std::move(other[i]);
307  }
308  empty_ = other.empty_;
309  other.empty_ = true;
310  return *this;
311  }
*than *hazptr_holder h
Definition: Hazptr.h:116
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
**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
template<uint8_t M, template< typename > class Atom>
FOLLY_ALWAYS_INLINE hazptr_holder<Atom>& folly::hazptr_array< M, Atom >::operator[] ( uint8_t  i)
inlinenoexcept

[] operator

Definition at line 314 of file HazptrHolder.h.

314  {
315  auto h = reinterpret_cast<hazptr_holder<Atom>*>(&raw_);
316  DCHECK(i < M);
317  return h[i];
318  }
*than *hazptr_holder h
Definition: Hazptr.h:116
aligned_hazptr_holder< Atom > raw_[M]
Definition: HazptrHolder.h:218
**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>
bool folly::hazptr_array< M, Atom >::empty_ {false}
private

Definition at line 221 of file HazptrHolder.h.

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

Definition at line 218 of file HazptrHolder.h.


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