rippled
Functions
Copy-on-Write Support

By nature, a node may appear in multiple SHAMap instances. Rather than actually duplicating these nodes, SHAMap opts to be memory efficient and uses copy-on-write semantics for nodes. More...

Functions

std::uint32_t ripple::SHAMapTreeNode::cowid () const
 Returns the SHAMap that owns this node. More...
 
void ripple::SHAMapTreeNode::unshare ()
 If this node is shared with another map, mark it as no longer shared. More...
 
virtual std::shared_ptr< SHAMapTreeNoderipple::SHAMapTreeNode::clone (std::uint32_t cowid) const =0
 Make a copy of this node, setting the owner. More...
 

Detailed Description

By nature, a node may appear in multiple SHAMap instances. Rather than actually duplicating these nodes, SHAMap opts to be memory efficient and uses copy-on-write semantics for nodes.

Only nodes that are not modified and don't need to be flushed back can be shared. Once a node needs to be changed, it must first be copied and the copy must marked as not shareable.

Note that just because a node may not be owned by a given SHAMap instance does not mean that the node is NOT a part of any SHAMap. It only means that the node is not owned exclusively by any one SHAMap.

For more on copy-on-write, check out: https://en.wikipedia.org/wiki/Copy-on-write

Function Documentation

◆ cowid()

std::uint32_t ripple::SHAMapTreeNode::cowid ( ) const

Returns the SHAMap that owns this node.

Returns
the ID of the SHAMap that owns this node, or 0 if the node is not owned by any SHAMap and is a candidate for sharing.

Definition at line 116 of file SHAMapTreeNode.h.

◆ unshare()

void ripple::SHAMapTreeNode::unshare ( )

If this node is shared with another map, mark it as no longer shared.

Only nodes that are not modified and do not need to be flushed back should be marked as unshared.

Definition at line 127 of file SHAMapTreeNode.h.

◆ clone()

virtual std::shared_ptr<SHAMapTreeNode> ripple::SHAMapTreeNode::clone ( std::uint32_t  cowid) const
pure virtual