| 
    rippled
    
   | 
 
A shared intrusive pointer class that supports weak pointers. More...
#include <IntrusivePointer.h>
Public Member Functions | |
| SharedIntrusive ()=default | |
| template<CAdoptTag TAdoptTag> | |
| SharedIntrusive (T *p, TAdoptTag) noexcept | |
| SharedIntrusive (SharedIntrusive const &rhs) | |
| template<class TT >  requires std::convertible_to<TT*, T*>  | |
| SharedIntrusive (SharedIntrusive< TT > const &rhs) | |
| SharedIntrusive (SharedIntrusive &&rhs) | |
| template<class TT >  requires std::convertible_to<TT*, T*>  | |
| SharedIntrusive (SharedIntrusive< TT > &&rhs) | |
| SharedIntrusive & | operator= (SharedIntrusive const &rhs) | 
| bool | operator!= (std::nullptr_t) const | 
| bool | operator== (std::nullptr_t) const | 
| template<class TT >  requires std::convertible_to<TT*, T*>  | |
| SharedIntrusive & | operator= (SharedIntrusive< TT > const &rhs) | 
| SharedIntrusive & | operator= (SharedIntrusive &&rhs) | 
| template<class TT >  requires std::convertible_to<TT*, T*>  | |
| SharedIntrusive & | operator= (SharedIntrusive< TT > &&rhs) | 
| template<CAdoptTag TAdoptTag = SharedIntrusiveAdoptIncrementStrongTag> | |
| void | adopt (T *p) | 
| Adopt the raw pointer.   | |
| ~SharedIntrusive () | |
| template<class TT > | |
| SharedIntrusive (StaticCastTagSharedIntrusive, SharedIntrusive< TT > const &rhs) | |
| Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.   | |
| template<class TT > | |
| SharedIntrusive (StaticCastTagSharedIntrusive, SharedIntrusive< TT > &&rhs) | |
| Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.   | |
| template<class TT > | |
| SharedIntrusive (DynamicCastTagSharedIntrusive, SharedIntrusive< TT > const &rhs) | |
| Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.   | |
| template<class TT > | |
| SharedIntrusive (DynamicCastTagSharedIntrusive, SharedIntrusive< TT > &&rhs) | |
| Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.   | |
| T & | operator* () const noexcept | 
| T * | operator-> () const noexcept | 
| operator bool () const noexcept | |
| void | reset () | 
| Set the pointer to null, decrement the strong count, and run the appropriate release action.   | |
| T * | get () const | 
| Get the raw pointer.   | |
| std::size_t | use_count () const | 
| Return the strong count.   | |
Private Member Functions | |
| T * | unsafeGetRawPtr () const | 
| Return the raw pointer held by this object.   | |
| void | unsafeReleaseAndStore (T *next) | 
| Exchange the current raw pointer held by this object with the given pointer.   | |
| void | unsafeSetRawPtr (T *p) | 
| Set the raw pointer directly.   | |
| T * | unsafeExchange (T *p) | 
| Exchange the raw pointer directly.   | |
Private Attributes | |
| T * | ptr_ {nullptr} | 
| pointer to the type with an intrusive count   | |
Friends | |
| template<class TT > | |
| class | SharedIntrusive | 
| template<class TT > | |
| class | SharedWeakUnion | 
| template<class TT > | |
| class | WeakIntrusive | 
| template<class TT , class... Args> | |
| SharedIntrusive< TT > | make_SharedIntrusive (Args &&... args) | 
| Create a shared intrusive pointer.   | |
A shared intrusive pointer class that supports weak pointers.
This is meant to be used for SHAMapInnerNodes, but may be useful for other cases. Since the reference counts are stored on the pointee, the pointee is not destroyed until both the strong and weak pointer counts go to zero. When the strong pointer count goes to zero, the "partialDestructor" is called. This can be used to destroy as much of the object as possible while still retaining the reference counts. For example, for SHAMapInnerNodes the children may be reset in that function. Note that std::shared_poiner WILL run the destructor when the strong count reaches zero, but may not free the memory used by the object until the weak count reaches zero. In rippled, we typically allocate shared pointers with the make_shared function. When that is used, the memory is not reclaimed until the weak count reaches zero. 
Definition at line 87 of file IntrusivePointer.h.
      
  | 
  default | 
      
  | 
  noexcept | 
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | SharedIntrusive< T > const & | rhs | ) | 
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | SharedIntrusive< TT > const & | rhs | ) | 
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | SharedIntrusive< T > && | rhs | ) | 
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | SharedIntrusive< TT > && | rhs | ) | 
| ripple::SharedIntrusive< T >::~SharedIntrusive | ( | ) | 
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | StaticCastTagSharedIntrusive< T > | , | 
| SharedIntrusive< TT > const & | rhs | ||
| ) | 
Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | StaticCastTagSharedIntrusive< T > | , | 
| SharedIntrusive< TT > && | rhs | ||
| ) | 
Create a new SharedIntrusive by statically casting the pointer controlled by the rhs param.
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | DynamicCastTagSharedIntrusive< T > | , | 
| SharedIntrusive< TT > const & | rhs | ||
| ) | 
Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.
| ripple::SharedIntrusive< T >::SharedIntrusive | ( | DynamicCastTagSharedIntrusive< T > | , | 
| SharedIntrusive< TT > && | rhs | ||
| ) | 
Create a new SharedIntrusive by dynamically casting the pointer controlled by the rhs param.
| SharedIntrusive & ripple::SharedIntrusive< T >::operator= | ( | SharedIntrusive< T > const & | rhs | ) | 
| bool ripple::SharedIntrusive< T >::operator!= | ( | std::nullptr_t | ) | const | 
| bool ripple::SharedIntrusive< T >::operator== | ( | std::nullptr_t | ) | const | 
| SharedIntrusive & ripple::SharedIntrusive< T >::operator= | ( | SharedIntrusive< TT > const & | rhs | ) | 
| SharedIntrusive & ripple::SharedIntrusive< T >::operator= | ( | SharedIntrusive< T > && | rhs | ) | 
| SharedIntrusive & ripple::SharedIntrusive< T >::operator= | ( | SharedIntrusive< TT > && | rhs | ) | 
| void ripple::SharedIntrusive< T >::adopt | ( | T * | p | ) | 
Adopt the raw pointer.
The strong reference may or may not be incremented, depending on the TAdoptTag
      
  | 
  noexcept | 
      
  | 
  noexcept | 
      
  | 
  explicitnoexcept | 
| void ripple::SharedIntrusive< T >::reset | ( | ) | 
Set the pointer to null, decrement the strong count, and run the appropriate release action.
| T * ripple::SharedIntrusive< T >::get | ( | ) | const | 
Get the raw pointer.
| std::size_t ripple::SharedIntrusive< T >::use_count | ( | ) | const | 
Return the strong count.
      
  | 
  private | 
Return the raw pointer held by this object.
      
  | 
  private | 
Exchange the current raw pointer held by this object with the given pointer.
Decrement the strong count of the raw pointer previously held by this object and run the appropriate release action.
      
  | 
  private | 
Set the raw pointer directly.
This is wrapped in a function so the class can support both atomic and non-atomic pointers in a future patch.
      
  | 
  private | 
Exchange the raw pointer directly.
This sets the raw pointer to the given value and returns the previous value. This is wrapped in a function so the class can support both atomic and non-atomic pointers in a future patch.
Definition at line 196 of file IntrusivePointer.h.
Definition at line 199 of file IntrusivePointer.h.
Definition at line 202 of file IntrusivePointer.h.
      
  | 
  friend | 
Create a shared intrusive pointer.
Note: unlike std::shared_ptr, where there is an advantage of allocating the pointer and control block together, there is no benefit for intrusive pointers.
Definition at line 467 of file IntrusivePointer.h.
      
  | 
  private | 
pointer to the type with an intrusive count
Definition at line 231 of file IntrusivePointer.h.