|
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 96 of file IntrusiveRefCounts.h.
|
private |
Definition at line 99 of file IntrusiveRefCounts.h.
|
virtualnoexcept |
Definition at line 406 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 238 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 244 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::releaseStrongRef | ( | ) | const |
Definition at line 250 of file IntrusiveRefCounts.h.
| ReleaseStrongRefAction xrpl::IntrusiveRefCounts::addWeakReleaseStrongRef | ( | ) | const |
Definition at line 298 of file IntrusiveRefCounts.h.
| ReleaseWeakRefAction xrpl::IntrusiveRefCounts::releaseWeakRef | ( | ) | const |
Definition at line 347 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 376 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 393 of file IntrusiveRefCounts.h.
|
noexcept |
Definition at line 400 of file IntrusiveRefCounts.h.
|
friend |
Definition at line 457 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 97 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 98 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 100 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Definition at line 101 of file IntrusiveRefCounts.h.
|
mutableprivate |
refCounts consists of four fields that are treated atomically:
Definition at line 136 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 144 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 152 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 161 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 175 of file IntrusiveRefCounts.h.
Mask that will zero out the tag bits and leave the count bits unchanged.
Definition at line 181 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the strong count.
Definition at line 186 of file IntrusiveRefCounts.h.
|
staticconstexprprivate |
Mask that will zero out everything except the weak count.
Definition at line 191 of file IntrusiveRefCounts.h.