|
xrpld
|
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 | useCount () const noexcept |
Private Types | |
| using | CountType = std::uint16_t |
| using | FieldType = std::uint32_t |
Private Attributes | |
| std::atomic< FieldType > | refCounts_ {kStrongDelta} |
| refCounts consists of four fields that are treated atomically: | |
Static Private Attributes | |
| static constexpr size_t | kStrongCountNumBits = sizeof(CountType) * 8 |
| static constexpr size_t | kWeakCountNumBits = kStrongCountNumBits - 2 |
| static constexpr size_t | kFieldTypeBits = sizeof(FieldType) * 8 |
| static constexpr FieldType | kOne = 1 |
| static constexpr FieldType | kStrongDelta = 1 |
| Amount to change the strong count when adding or releasing a reference. | |
| static constexpr FieldType | kWeakDelta = (kOne << kStrongCountNumBits) |
| Amount to change the weak count when adding or releasing a reference. | |
| static constexpr FieldType | kPartialDestroyStartedMask = (kOne << (kFieldTypeBits - 1)) |
| Flag that is set when the partialDestroy function has started running (or is about to start running). | |
| static constexpr FieldType | kPartialDestroyFinishedMask = (kOne << (kFieldTypeBits - 2)) |
| Flag that is set when the partialDestroy function has finished running. | |
| static constexpr FieldType | kTagMask = kPartialDestroyStartedMask | kPartialDestroyFinishedMask |
| Mask that will zero out all the count bits and leave the tag bits unchanged. | |
| static constexpr FieldType | kValueMask = ~kTagMask |
| Mask that will zero out the tag bits and leave the count bits unchanged. | |
| static constexpr FieldType | kStrongMask = ((kOne << kStrongCountNumBits) - 1) & kValueMask |
| Mask that will zero out everything except the strong count. | |
| static constexpr FieldType | kWeakMask |
| 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 an xrpl::IntrusivePointer by inheriting from this class.
Definition at line 39 of file IntrusiveRefCounts.h.
|
private |
Definition at line 100 of file IntrusiveRefCounts.h.
|
private |
Definition at line 103 of file IntrusiveRefCounts.h.
|
virtualnoexcept |
Definition at line 397 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 227 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 233 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::releaseStrongRef | ( | ) | const |
Definition at line 239 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef | ( | ) | const |
Definition at line 287 of file IntrusiveRefCounts.h.
| ReleaseWeakRefAction xrpl::IntrusiveRefCounts::releaseWeakRef | ( | ) | const |
Definition at line 340 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 367 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 384 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 391 of file IntrusiveRefCounts.h.
|
friend |
Definition at line 448 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 101 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 102 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 104 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 105 of file IntrusiveRefCounts.h.
|
mutableprivate |
refCounts consists of four fields that are treated atomically:
Definition at line 140 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 147 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 154 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 162 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 169 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out all the count bits and leave the tag bits unchanged.
Definition at line 174 of file IntrusiveRefCounts.h.
Mask that will zero out the tag bits and leave the count bits unchanged.
Definition at line 179 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the strong count.
Definition at line 183 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the weak count.
Definition at line 187 of file IntrusiveRefCounts.h.