Broom 1.0.0
A thread-local C++ Garbage Collector
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
broom::BroomValue Class Referenceabstract

#include <broom.h>

Inheritance diagram for broom::BroomValue:
Inheritance graph
[legend]

Public Member Functions

virtual ~BroomValue ()
 
virtual void Visit (Visitor *visitor) const =0
 

Protected Member Functions

 BroomValue (GarbageCollector *gc)
 
 BroomValue ()
 
 BroomValue (const BroomValue &other)
 
BroomValueoperator= (const BroomValue &other)
 
BroomValueoperator= (BroomValue &&other) noexcept
 

Detailed Description

BroomValue implements the notion of a precise garbage collector root via inheritance. Every class/struct that inherits from this class needs to call the BroomValue::BroomValue() constructor for every one of its constructors. Additionally, every class that inherits from BroomValue must also implement the BroomValue::Visit() method and call Visitor::Visit() on any member that may be a managed object.

class Foo : public BroomValue {
public:
Foo(...) : BroomValue(), ... {
...
}
virtual void Visit(Visitor* visitor) const {
visitor->Visit(ptr_2);
...
}
};
virtual void Visit(Visitor *visitor) const =0
std::queue< T, broom::deque< T > > queue
Definition broom-queue.h:12

gc_root is also available as a type alias for this class to support a more traditional C++ style.

Definition at line 402 of file broom.h.

Constructor & Destructor Documentation

◆ ~BroomValue()

broom::BroomValue::~BroomValue ( )
virtual

Definition at line 52 of file api.cc.

◆ BroomValue() [1/3]

broom::BroomValue::BroomValue ( GarbageCollector gc)
protected

A constructor accepting a garbage collector state.

Parameters
gcThe garbage collector state that this BroomValue belongs to.

Definition at line 48 of file api.cc.

◆ BroomValue() [2/3]

broom::BroomValue::BroomValue ( )
protected

The default constructor. This is the one that should be used by most classes inheriting from BroomValue.

Definition at line 50 of file api.cc.

◆ BroomValue() [3/3]

broom::BroomValue::BroomValue ( const BroomValue other)
protected

Copy constructor. This constructor won't re-register the root with the garbage collector.

Parameters
otherThe BroomValue object to copy.

Definition at line 51 of file api.cc.

Member Function Documentation

◆ operator=() [1/2]

BroomValue & broom::BroomValue::operator= ( BroomValue &&  other)
protectednoexcept

Assignment operator with an rvalue reference. This constructor will unregister other with the garbage collector state and register this instance instead. The operator is guarded against self-assignment.

Parameters
otherThe rvalue reference of the BroomValue object to assign.

Definition at line 64 of file api.cc.

◆ operator=() [2/2]

BroomValue & broom::BroomValue::operator= ( const BroomValue other)
protected

Assignment operator with a reference. This constructor will unregister other with the garbage collector state and register this instance instead. The operator is guarded against self-assignment.

Parameters
otherThe reference of the BroomValue object to assign.

Definition at line 54 of file api.cc.

◆ Visit()

virtual void broom::BroomValue::Visit ( Visitor visitor) const
pure virtual

An abstract Visit() method that needs to be implemented by any class that inherits from this class. The Visit() method is expected to call the visitor's Visitor::Visit() method on any managed pointer member.

Parameters
visitorThe Visitor object that implements a Visitor::Visit() method.

Implemented in broom::map< Key, T, Compare, Allocator >, broom::multimap< Key, T, Compare, Allocator >, broom::unordered_map< Key, T, Hash, KeyEqual, Allocator >, broom::unordered_map< std::string, Node * >, and broom::unordered_multimap< Key, T, Hash, KeyEqual, Allocator >.


The documentation for this class was generated from the following files: