gem5  v21.1.0.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
gem5::RefCounted Class Reference

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

#include <refcnt.hh>

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

Constructor & Destructor Documentation

◆ RefCounted() [1/2]

gem5::RefCounted::RefCounted ( const RefCounted )
private

◆ RefCounted() [2/2]

gem5::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 84 of file refcnt.hh.

◆ ~RefCounted()

virtual gem5::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 95 of file refcnt.hh.

Member Function Documentation

◆ decref()

void gem5::RefCounted::decref ( ) const
inline

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

Definition at line 103 of file refcnt.hh.

References count.

◆ incref()

void gem5::RefCounted::incref ( ) const
inline

Increment the reference count.

Definition at line 98 of file refcnt.hh.

References count.

◆ operator=()

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

Member Data Documentation

◆ count

int gem5::RefCounted::count
mutableprivate

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

Generated on Tue Sep 21 2021 12:28:00 for gem5 by doxygen 1.8.17