proxygen
folly::HazptrWideCAS< T, Atom > Class Template Reference

#include <HazptrWideCAS.h>

Classes

struct  Node
 

Public Member Functions

 HazptrWideCAS ()
 
 ~HazptrWideCAS ()
 
bool cas (T &u, T &v)
 

Private Attributes

Atom< Node * > node_
 

Detailed Description

template<typename T, template< typename > class Atom = std::atomic>
class folly::HazptrWideCAS< T, Atom >

Wide CAS.

Definition at line 27 of file HazptrWideCAS.h.

Constructor & Destructor Documentation

template<typename T, template< typename > class Atom = std::atomic>
folly::HazptrWideCAS< T, Atom >::HazptrWideCAS ( )
inline

Definition at line 36 of file HazptrWideCAS.h.

36 : node_(new Node()) {}
Atom< Node * > node_
Definition: HazptrWideCAS.h:33
template<typename T, template< typename > class Atom = std::atomic>
folly::HazptrWideCAS< T, Atom >::~HazptrWideCAS ( )
inline

Definition at line 38 of file HazptrWideCAS.h.

38  {
39  delete node_.load(std::memory_order_relaxed);
40  }
Atom< Node * > node_
Definition: HazptrWideCAS.h:33

Member Function Documentation

template<typename T, template< typename > class Atom = std::atomic>
bool folly::HazptrWideCAS< T, Atom >::cas ( T u,
T v 
)
inline

Definition at line 42 of file HazptrWideCAS.h.

References folly::hazptr_holder< Atom >::get_protected(), folly::HazptrWideCAS< T, Atom >::Node::Node(), folly::hazptr_holder< Atom >::reset(), folly::hazptr_obj_base< T, Atom, D >::retire(), and folly::HazptrWideCAS< T, Atom >::Node::val_.

Referenced by wide_cas_test().

42  {
43  Node* n = new Node(v);
44  hazptr_holder<Atom> hptr;
45  Node* p;
46  while (true) {
47  p = hptr.get_protected(node_);
48  if (p->val_ != u) {
49  delete n;
50  return false;
51  }
52  if (node_.compare_exchange_weak(
53  p, n, std::memory_order_relaxed, std::memory_order_release)) {
54  break;
55  }
56  }
57  hptr.reset();
58  p->retire();
59  return true;
60  }
void retire(D deleter={}, hazptr_domain< Atom > &domain=default_hazptr_domain< Atom >())
Definition: HazptrObj.h:229
int val_
Definition: HazptrTest.cpp:99
Atom< Node * > node_
Definition: HazptrWideCAS.h:33

Member Data Documentation

template<typename T, template< typename > class Atom = std::atomic>
Atom<Node*> folly::HazptrWideCAS< T, Atom >::node_
private

Definition at line 33 of file HazptrWideCAS.h.


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