MythTV  master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ReferenceCounter Class Reference

General purpose reference counter. More...

#include <referencecounter.h>

Inheritance diagram for ReferenceCounter:
Inheritance graph
[legend]

Public Member Functions

 ReferenceCounter (const QString &debugName, bool logDebug=true)
 Creates reference counter with an initial value of 1. More...
 
virtual int IncrRef (void)
 Increments reference count. More...
 
virtual int DecrRef (void)
 Decrements reference count and deletes on 0. More...
 

Static Public Member Functions

static void PrintDebug (void)
 Print out any leaks if that level of debugging is enabled. More...
 

Protected Member Functions

virtual ~ReferenceCounter (void)
 Called on destruction, will warn if object deleted with references in place. More...
 

Protected Attributes

bool m_logDebug
 This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More...
 
QAtomicInt m_referenceCount {1}
 

Detailed Description

General purpose reference counter.

This class uses QAtomicInt for lockless reference counting.

Definition at line 26 of file referencecounter.h.

Constructor & Destructor Documentation

◆ ReferenceCounter()

ReferenceCounter::ReferenceCounter ( const QString &  debugName,
bool  logDebug = true 
)
explicit

Creates reference counter with an initial value of 1.

Definition at line 75 of file referencecounter.cpp.

◆ ~ReferenceCounter()

ReferenceCounter::~ReferenceCounter ( void  )
protectedvirtual

Called on destruction, will warn if object deleted with references in place.

Set breakpoint here for debugging.

Definition at line 88 of file referencecounter.cpp.

Member Function Documentation

◆ IncrRef()

int ReferenceCounter::IncrRef ( void  )
virtual

Increments reference count.

Returns
last reference count

Reimplemented in MythImage.

Definition at line 101 of file referencecounter.cpp.

Referenced by MythVDPAUInterop::Acquire(), MythPower::AcquireRelease(), TV::AcquireRelease(), SSDPCache::Add(), UPnpCDSExtensionResults::Add(), MythCommandLineParser::add(), CDSObject::AddChild(), DeleteThread::AddFile(), BackendSelection::AddItem(), MythSocketManager::AddSocketHandler(), TaskQueue::AddTaskAbsolute(), MythSystemLegacyManager::append(), BEProcessRequestRunnable::BEProcessRequestRunnable(), MainServer::connectionClosed(), MythCodecContext::CreateDevice(), SSDPCacheEntries::Find(), MythSocketManager::GetConnectionBySocket(), MythDVDBuffer::GetDVDContext(), SSDPCacheEntries::GetFirst(), GuideGrid::GuideGrid(), MainServer::HandleAnnounce(), FileServerHandler::HandleFileQuery(), MainServer::HandleFileTransferQuery(), FileServerHandler::HandleGetFileList(), FileServerHandler::HandleQueryFileTransfer(), EncoderLink::HasSockAndIncrRef(), MythImage::IncrRef(), SSDPCacheEntries::Insert(), LoggerThread::logConsole(), logForwardMessage(), MythD3D9Painter::MythD3D9Painter(), MythInteropGPU::MythInteropGPU(), MythOpenGLTonemap::MythOpenGLTonemap(), MythVideoDRM::MythVideoDRM(), MythVideoGPU::MythVideoGPU(), MythVideoOutputGPU::MythVideoOutputGPU(), GameUI::OnGameSearchListSelection(), MetadataFactory::OnSingleResult(), VideoDialog::OnVideoSearchListSelection(), PlaybackBox::PlaybackBox(), ProcessRequestRunnable::ProcessRequestRunnable(), ProgFinder::ProgFinder(), PlaybackSock::ReadStringList(), SSDPCache::Remove(), SSDPCache::RemoveStale(), MetadataDownload::run(), ScheduleEditor::ScheduleEditor(), PlaybackSock::SendReceiveStringList(), CommandLineArg::SetBlocks(), CommandLineArg::SetChildOf(), CommandLineArg::SetParentOf(), CommandLineArg::SetRequires(), EncoderLink::SetSocket(), SocketHandler::SocketHandler(), TVRec::SpawnLiveTV(), and ViewScheduled::ViewScheduled().

◆ DecrRef()

int ReferenceCounter::DecrRef ( void  )
virtual

Decrements reference count and deletes on 0.

Returns
last reference count, 0 if deleted

Reimplemented in MythImage.

Definition at line 125 of file referencecounter.cpp.

Referenced by MythPower::AcquireRelease(), TV::AcquireRelease(), SSDPCache::Add(), MetadataImageDownload::addDownloads(), MetadataDownload::addLookup(), RemoteFile::Close(), MythDVDBuffer::CloseDVD(), MythCoreContext::ConnectCommandSocket(), MythSocketManager::connectionClosed(), MainServer::connectionClosed(), ZMClient::connectToHost(), MythCoreContext::ConnectToMasterServer(), CreateMetadataXML(), BackendSelection::customEvent(), MythImage::DecrRef(), MythContextPrivate::DefaultUPnP(), MainServer::deferredDeleteSlot(), MainServer::DeleteChain(), VideoOutputD3D::DestroyContext(), MythCodecContext::DestroyInterop(), OutboundRequestHandler::DoConnectToMaster(), MainServer::DoHandleDeleteRecording(), MainServer::DoHandleStopRecording(), SatIP::doUPNPsearch(), VBox::doUPNPSearch(), HttpStatus::FillStatusXML(), V2Status::FillStatusXML(), SSDPCache::Find(), FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), MainServer::HandleCheckRecordingActive(), FileServerHandler::HandleFileQuery(), MainServer::HandleFileTransferQuery(), MainServer::HandleGenPreviewPixmap(), FileServerHandler::HandleGetFileList(), MainServer::HandleIsActiveBackendQuery(), MainServer::HandleMusicCalcTrackLen(), MainServer::HandleMusicFindAlbumArt(), MainServer::HandleMusicFindLyrics(), MainServer::HandleMusicSaveLyrics(), MainServer::HandleMusicTagAddImage(), MainServer::HandleMusicTagChangeImage(), MainServer::HandleMusicTagGetImage(), MainServer::HandleMusicTagRemoveImage(), MainServer::HandleMusicTagUpdateMetadata(), MainServer::HandleMusicTagUpdateVolatile(), MainServer::HandlePixmapGetIfModified(), MainServer::HandlePixmapLastModified(), MainServer::HandleQueryCheckFile(), MainServer::HandleQueryFileHash(), FileServerHandler::HandleQueryFileTransfer(), MainServer::HandleQueryFindFile(), MainServer::HandleQueryRecordings(), MainServer::HandleScanMusic(), MainServer::HandleSGFileQuery(), MainServer::HandleSGGetFileList(), EncoderLink::HasSockAndDecrRef(), BackendSelection::Init(), MythVAAPIContext::InitialiseContext(), UPnpCDSMusic::LoadAlbums(), UPnpCDSMusic::LoadArtists(), UPnpCDSTv::LoadChannels(), UPnpCDSTv::LoadDates(), UPnpCDSTv::LoadGenres(), UPnpCDSVideo::LoadGenres(), UPnpCDSMusic::LoadGenres(), UPnpCDSTv::LoadRecGroups(), UPnpCDSTv::LoadRecordings(), UPnpCDSVideo::LoadSeasons(), UPnpCDSVideo::LoadSeries(), UPnpCDSTv::LoadTitles(), UPnpCDSMusic::LoadTracks(), UPnpCDSVideo::LoadVideos(), LoggerThread::logConsole(), LogPrintLine(), MythDVDBuffer::OpenFile(), GuideGrid::PlayerExiting(), MetadataDownload::prependLookup(), DeleteThread::ProcessNew(), DeleteThread::ProcessOld(), HouseKeeper::RegisterTask(), MythDVDDecoder::ReleaseContext(), RemoteGetFileList(), RemoteSendReceiveStringList(), SSDPCache::Remove(), SSDPCache::RemoveStale(), ProcessRequestRunnable::run(), MythSystemLegacySignalManager::run(), TaskQueue::run(), LogForwardThread::run(), LoggerThread::run(), BEProcessRequestRunnable::run(), MythDVDBuffer::SafeRead(), RemoteEncoder::SendReceiveStringList(), PlaybackSock::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), PlayerContext::SetTVChain(), MythDVDBuffer::StartFromBeginning(), TVRec::StartRecording(), TVRec::StopLiveTV(), MythD3D9Painter::Teardown(), MythContextPrivate::UPnPautoconf(), BEFileTransfer::~BEFileTransfer(), BEProcessRequestRunnable::~BEProcessRequestRunnable(), GuideGrid::~GuideGrid(), MetadataFactoryNoResult::~MetadataFactoryNoResult(), MetadataFactorySingleResult::~MetadataFactorySingleResult(), MythInteropGPU::~MythInteropGPU(), MythOpenGLTonemap::~MythOpenGLTonemap(), MythPainterWindowOpenGL::~MythPainterWindowOpenGL(), MythSystemLegacy::~MythSystemLegacy(), MythVDPAUInterop::~MythVDPAUInterop(), MythVideoDRM::~MythVideoDRM(), MythVideoGPU::~MythVideoGPU(), MythVideoOutputGPU::~MythVideoOutputGPU(), PlaybackBox::~PlaybackBox(), PlaybackSock::~PlaybackSock(), ProgFinder::~ProgFinder(), RemoteEncoder::~RemoteEncoder(), RemoteFile::~RemoteFile(), ScheduleEditor::~ScheduleEditor(), SocketHandler::~SocketHandler(), SSDP::~SSDP(), UPnpCDSExtension::~UPnpCDSExtension(), ViewScheduled::~ViewScheduled(), and ZMClient::~ZMClient().

◆ PrintDebug()

void ReferenceCounter::PrintDebug ( void  )
static

Print out any leaks if that level of debugging is enabled.

Definition at line 72 of file referencecounter.cpp.

Referenced by CleanupGuard::~CleanupGuard().

Member Data Documentation

◆ m_logDebug

bool ReferenceCounter::m_logDebug
protected

This is used to suppress creating LoggingItem classes for LoggingItem reference count changes.

This is necessary to prevent infinte recursion. If you need to debug LoggingItem reference counting you need to print the messages to the console by modifying IncrRef() and DecrRef().

Definition at line 56 of file referencecounter.h.

Referenced by DecrRef(), and IncrRef().

◆ m_referenceCount

QAtomicInt ReferenceCounter::m_referenceCount {1}
protected

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