| 
    rippled
    
   | 
 
Implement the strong count, weak count, and bit flags for an intrusive pointer. More...
#include <IntrusiveRefCounts.h>


Classes | |
| struct | RefCountPair | 
| Unpack the count and tag fields from the packed atomic integer form.  More... | |
Public Member Functions | |
| virtual | ~IntrusiveRefCounts () noexcept | 
| void | addStrongRef () const noexcept | 
| void | addWeakRef () const noexcept | 
| ReleaseStrongRefAction | releaseStrongRef () const | 
| ReleaseStrongRefAction | addWeakReleaseStrongRef () const | 
| ReleaseWeakRefAction | releaseWeakRef () const | 
| bool | checkoutStrongRefFromWeak () const noexcept | 
| bool | expired () const noexcept | 
| std::size_t | use_count () const noexcept | 
Private Types | |
| using | CountType = std::uint16_t | 
| using | FieldType = std::uint32_t | 
Private Attributes | |
| std::atomic< FieldType > | refCounts {strongDelta} | 
refCounts consists of four fields that are treated atomically:   | |
Static Private Attributes | |
| static constexpr size_t | StrongCountNumBits = sizeof(CountType) * 8 | 
| static constexpr size_t | WeakCountNumBits = StrongCountNumBits - 2 | 
| static constexpr size_t | FieldTypeBits = sizeof(FieldType) * 8 | 
| static constexpr FieldType | one = 1 | 
| static constexpr FieldType | strongDelta = 1 | 
| Amount to change the strong count when adding or releasing a reference.   | |
| static constexpr FieldType | weakDelta = (one << StrongCountNumBits) | 
| Amount to change the weak count when adding or releasing a reference.   | |
| static constexpr FieldType | partialDestroyStartedMask | 
| Flag that is set when the partialDestroy function has started running (or is about to start running).   | |
| static constexpr FieldType | partialDestroyFinishedMask | 
| Flag that is set when the partialDestroy function has finished running.   | |
| static constexpr FieldType | tagMask | 
Mask that will zero out all the count bits and leave the tag bits unchanged.   | |
| static constexpr FieldType | valueMask = ~tagMask | 
Mask that will zero out the tag bits and leave the count bits unchanged.   | |
| static constexpr FieldType | strongMask | 
| Mask that will zero out everything except the strong count.   | |
| static constexpr FieldType | weakMask | 
| Mask that will zero out everything except the weak count.   | |
Friends | |
| template<class T > | |
| void | partialDestructorFinished (T **o) | 
Implement the strong count, weak count, and bit flags for an intrusive pointer.
A class can satisfy the requirements of a ripple::IntrusivePointer by inheriting from this class.
Definition at line 59 of file IntrusiveRefCounts.h.
      
  | 
  private | 
Definition at line 120 of file IntrusiveRefCounts.h.
      
  | 
  private | 
Definition at line 123 of file IntrusiveRefCounts.h.
      
  | 
  virtualnoexcept | 
Definition at line 424 of file IntrusiveRefCounts.h.
      
  | 
  noexcept | 
Definition at line 251 of file IntrusiveRefCounts.h.
      
  | 
  noexcept | 
Definition at line 257 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction ripple::IntrusiveRefCounts::releaseStrongRef | ( | ) | const | 
Definition at line 263 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction ripple::IntrusiveRefCounts::addWeakReleaseStrongRef | ( | ) | const | 
Definition at line 312 of file IntrusiveRefCounts.h.
| ReleaseWeakRefAction ripple::IntrusiveRefCounts::releaseWeakRef | ( | ) | const | 
Definition at line 366 of file IntrusiveRefCounts.h.
      
  | 
  noexcept | 
Definition at line 393 of file IntrusiveRefCounts.h.
      
  | 
  noexcept | 
Definition at line 411 of file IntrusiveRefCounts.h.
      
  | 
  noexcept | 
Definition at line 418 of file IntrusiveRefCounts.h.
      
  | 
  friend | 
Definition at line 479 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Definition at line 121 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Definition at line 122 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Definition at line 124 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Definition at line 125 of file IntrusiveRefCounts.h.
      
  | 
  mutableprivate | 
refCounts consists of four fields that are treated atomically: 
partialDestructor function has been started (or is about to be started). This is used to prevent the destructor from running concurrently with the partial destructor. This can easily happen when the last strong pointer release its reference in one thread and starts the partialDestructor, while in another thread the last weak pointer goes out of scope and starts the destructor while the partialDestructor is still running. Both a start and finished bit is needed to handle a corner-case where the last strong pointer goes out of scope, then then last weakPointer goes out of scope, but this happens before the partialDestructor bit is set. It would be possible to use a single bit if it could also be set atomically when the strong count goes to zero and the weak count is non-zero, but that would add complexity (and likely slow down common cases as well).partialDestructor has finished running. See (3) above for more information. Definition at line 160 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Amount to change the strong count when adding or releasing a reference.
Note: The strong count is stored in the low StrongCountNumBits bits of refCounts 
Definition at line 167 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Amount to change the weak count when adding or releasing a reference.
Note: The weak count is stored in the high WeakCountNumBits bits of refCounts 
Definition at line 174 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Flag that is set when the partialDestroy function has started running (or is about to start running).
See description of the refCounts field for a fuller description of this field. 
Definition at line 182 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Flag that is set when the partialDestroy function has finished running.
See description of the refCounts field for a fuller description of this field. 
Definition at line 190 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Mask that will zero out all the count bits and leave the tag bits unchanged. 
Definition at line 196 of file IntrusiveRefCounts.h.
Mask that will zero out the tag bits and leave the count bits unchanged. 
Definition at line 202 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Mask that will zero out everything except the strong count.
Definition at line 206 of file IntrusiveRefCounts.h.
      
  | 
  staticconstexprprivate | 
Mask that will zero out everything except the weak count.
Definition at line 211 of file IntrusiveRefCounts.h.