|
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 43 of file IntrusiveRefCounts.h.
|
private |
Definition at line 104 of file IntrusiveRefCounts.h.
|
private |
Definition at line 107 of file IntrusiveRefCounts.h.
|
virtualnoexcept |
Definition at line 416 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 246 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 252 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::releaseStrongRef | ( | ) | const |
Definition at line 258 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef | ( | ) | const |
Definition at line 306 of file IntrusiveRefCounts.h.
| ReleaseWeakRefAction xrpl::IntrusiveRefCounts::releaseWeakRef | ( | ) | const |
Definition at line 359 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 386 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 403 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 410 of file IntrusiveRefCounts.h.
|
friend |
Definition at line 467 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 105 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 106 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 108 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 109 of file IntrusiveRefCounts.h.
|
mutableprivate |
refCounts consists of four fields that are treated atomically:
Definition at line 144 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 152 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 160 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 169 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 177 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out all the count bits and leave the tag bits unchanged.
Definition at line 183 of file IntrusiveRefCounts.h.
Mask that will zero out the tag bits and leave the count bits unchanged.
Definition at line 189 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the strong count.
Definition at line 194 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the weak count.
Definition at line 199 of file IntrusiveRefCounts.h.