gem5  v20.1.0.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
RefCounted Class Reference

Derive from RefCounted if you want to enable reference counting of this class. More...

#include <refcnt.hh>

Inheritance diagram for RefCounted:
BaseDynInst< Impl > Minor::MinorDynInst StaticInst BaseO3DynInst< Impl > ArmISA::ArmStaticInst PowerISA::PowerStaticInst RiscvISA::RiscvStaticInst SparcISA::SparcStaticInst X86ISA::X86StaticInst ArmISA::BranchEret64 ArmISA::BranchEretA64 ArmISA::BranchImm64 ArmISA::BranchImmImmReg64 ArmISA::BranchImmReg64 ArmISA::BranchReg64 ArmISA::BranchRegReg64 ArmISA::DataX1Reg2ImmOp ArmISA::DataX1RegImmOp ArmISA::DataX1RegOp ArmISA::DataX2RegImmOp ArmISA::DataX2RegOp ArmISA::DataX3RegOp ArmISA::DataXCondCompImmOp ArmISA::DataXCondCompRegOp ArmISA::DataXCondSelOp ArmISA::DataXERegOp ArmISA::DataXImmOnlyOp ArmISA::DataXImmOp ArmISA::DataXSRegOp ArmISA::MicroOpX ArmISA::MightBeMicro64 ArmISA::PredOp ArmISA::SveAdrOp ArmISA::SveBinConstrPredOp ArmISA::SveBinDestrPredOp ArmISA::SveBinIdxUnpredOp ArmISA::SveBinImmIdxUnpredOp ArmISA::SveBinImmPredOp ArmISA::SveBinImmUnpredConstrOp ArmISA::SveBinImmUnpredDestrOp ArmISA::SveBinUnpredOp ArmISA::SveBinWideImmUnpredOp ArmISA::SveCmpImmOp ArmISA::SveCmpOp ArmISA::SveComplexIdxOp ArmISA::SveComplexOp ArmISA::SveCompTermOp ArmISA::SveContigMemSI ArmISA::SveContigMemSS ArmISA::SveDotProdIdxOp ArmISA::SveDotProdOp ArmISA::SveElemCountOp ArmISA::SveIndexIIOp ArmISA::SveIndexIROp ArmISA::SveIndexRIOp ArmISA::SveIndexRROp ArmISA::SveIntCmpImmOp ArmISA::SveIntCmpOp ArmISA::SveMemPredFillSpill ArmISA::SveMemVecFillSpill ArmISA::SveOrdReducOp ArmISA::SvePartBrkOp ArmISA::SvePartBrkPropOp ArmISA::SvePredBinPermOp ArmISA::SvePredCountOp ArmISA::SvePredCountPredOp ArmISA::SvePredLogicalOp ArmISA::SvePredTestOp ArmISA::SvePredUnaryWImplicitDstOp ArmISA::SvePredUnaryWImplicitSrcOp ArmISA::SvePredUnaryWImplicitSrcPredOp ArmISA::SvePtrueOp ArmISA::SveReducOp ArmISA::SveSelectOp ArmISA::SveTblOp ArmISA::SveTerImmUnpredOp ArmISA::SveTerPredOp ArmISA::SveUnaryPredOp ArmISA::SveUnaryPredPredOp ArmISA::SveUnarySca2VecUnpredOp ArmISA::SveUnaryUnpredOp ArmISA::SveUnaryWideImmPredOp ArmISA::SveUnaryWideImmUnpredOp ArmISA::SveUnpackOp ArmISA::SveWhileOp ArmISA::SveWImplicitSrcDstOp ArmISAInst::TmeImmOp64 ArmISAInst::TmeRegNone64 DebugStep DecoderFaultInst FailUnimplemented IllegalExecInst ImmOp64 McrMrcMiscInst MiscRegOp64 RegNone RegRegImmImmOp64 RegRegRegImmOp64 UnknownOp64 WarnUnimplemented PowerISA::CondLogicOp PowerISA::CondMoveOp PowerISA::FloatOp PowerISA::IntOp PowerISA::MemOp PowerISA::MiscOp PowerISA::PCDependentDisassembly RiscvISA::CompRegOp RiscvISA::CSROp RiscvISA::ImmOp< I > RiscvISA::MemInst RiscvISA::PseudoOp RiscvISA::RegOp RiscvISA::RiscvMacroInst RiscvISA::RiscvMicroInst RiscvISA::SystemOp RiscvISA::Unknown SparcISA::Branch SparcISA::FailUnimplemented SparcISA::FpUnimpl SparcISA::IntOp SparcISA::Mem SparcISA::Nop SparcISA::Priv SparcISA::SparcMacroInst SparcISA::SparcMicroInst SparcISA::Trap SparcISA::Unknown SparcISA::WarnUnimplemented X86ISA::MacroopBase X86ISA::X86MicroopBase

Public Member Functions

 RefCounted ()
 We initialize the reference count to zero and the first object to take ownership of it must increment it to one. More...
 
virtual ~RefCounted ()
 We make the destructor virtual because we're likely to have virtual functions on reference counted objects. More...
 
void incref () const
 Increment the reference count. More...
 
void decref () const
 Decrement the reference count and destroy the object if all references are gone. More...
 

Private Member Functions

 RefCounted (const RefCounted &)
 
RefCountedoperator= (const RefCounted &)
 

Private Attributes

int count
 

Detailed Description

Derive from RefCounted if you want to enable reference counting of this class.

If you want to use automatic reference counting, you should use RefCountingPtr<T> instead of regular pointers.

Definition at line 57 of file refcnt.hh.

Constructor & Destructor Documentation

◆ RefCounted() [1/2]

RefCounted::RefCounted ( const RefCounted )
private

◆ RefCounted() [2/2]

RefCounted::RefCounted ( )
inline

We initialize the reference count to zero and the first object to take ownership of it must increment it to one.

Attention
A memory leak will occur if you never assign a newly constructed object to a reference counting pointer.

Definition at line 81 of file refcnt.hh.

◆ ~RefCounted()

virtual RefCounted::~RefCounted ( )
inlinevirtual

We make the destructor virtual because we're likely to have virtual functions on reference counted objects.

Todo:
Even if this were true, does it matter? Shouldn't the derived class indicate this? This only matters if we would ever choose to delete a "RefCounted *" which I doubt we'd ever do. We don't ever delete a "void *".

Definition at line 92 of file refcnt.hh.

Member Function Documentation

◆ decref()

void RefCounted::decref ( ) const
inline

Decrement the reference count and destroy the object if all references are gone.

Definition at line 99 of file refcnt.hh.

References count.

◆ incref()

void RefCounted::incref ( ) const
inline

Increment the reference count.

Definition at line 95 of file refcnt.hh.

References count.

◆ operator=()

RefCounted& RefCounted::operator= ( const RefCounted )
private

Member Data Documentation

◆ count

int RefCounted::count
mutableprivate

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

Generated on Wed Sep 30 2020 14:02:30 for gem5 by doxygen 1.8.17