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 
)

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 SSDPCache::Add(), UPnpCDSExtensionResults::Add(), MythCommandLineParser::add(), CDSObject::AddChild(), DeleteThread::AddFile(), BackendSelection::AddItem(), MythSocketManager::AddSocketHandler(), TaskQueue::AddTask(), MythSystemLegacyManager::append(), MainServer::connectionClosed(), DBLoggerThread::enqueue(), SSDPCacheEntries::Find(), MythSocketManager::GetConnectionBySocket(), VAAPIDisplay::GetDisplay(), DVDRingBuffer::GetDVDContext(), SSDPCacheEntries::GetFirst(), MainServer::HandleAnnounce(), FileServerHandler::HandleFileQuery(), MainServer::HandleFileTransferQuery(), FileServerHandler::HandleGetFileList(), FileServerHandler::HandleQueryFileTransfer(), EncoderLink::HasSockAndIncrRef(), MythImage::IncrRef(), SSDPCacheEntries::Insert(), LoggerThread::logConsole(), MythD3D9Painter::MythD3D9Painter(), MythVDPAUPainter::MythVDPAUPainter(), GameUI::OnGameSearchListSelection(), MetadataFactory::OnSingleResult(), ProcessRequestRunnable::ProcessRequestRunnable(), PlaybackSock::ReadStringList(), SSDPCache::Remove(), SSDPCache::RemoveStale(), MetadataDownload::run(), PlaybackSock::SendReceiveStringList(), CommandLineArg::SetBlocks(), CommandLineArg::SetChildOf(), CommandLineArg::SetParentOf(), CommandLineArg::SetRequires(), EncoderLink::SetSocket(), VideoOutputOpenGL::SetupContext(), SocketHandler::SocketHandler(), and TVRec::SpawnLiveTV().

◆ DecrRef()

int ReferenceCounter::DecrRef ( void  )
virtual

Decrements reference count and deletes on 0.

Returns
last reference count, 0 if deleted

Reimplemented in VAAPIDisplay, and MythImage.

Definition at line 125 of file referencecounter.cpp.

Referenced by SSDPCache::Add(), MetadataImageDownload::addDownloads(), MetadataDownload::addLookup(), RemoteFile::Close(), DVDRingBuffer::CloseDVD(), connect_to_master(), MythCoreContext::ConnectCommandSocket(), MythCoreContext::ConnectEventSocket(), MythSocketManager::connectionClosed(), MainServer::connectionClosed(), ZMClient::connectToHost(), MythCoreContext::ConnectToMasterServer(), CreateMetadataXML(), BackendSelection::customEvent(), MythImage::DecrRef(), VAAPIDisplay::DecrRef(), MythContextPrivate::DefaultUPnP(), MainServer::deferredDeleteSlot(), MainServer::DeleteChain(), VideoOutputNullVDPAU::DeleteRender(), VideoOutputVDPAU::DeleteRender(), VideoOutputD3D::DestroyContext(), OutboundRequestHandler::DoConnectToMaster(), MainServer::DoHandleDeleteRecording(), MainServer::DoHandleStopRecording(), VBox::doUPNPSearch(), HttpStatus::FillStatusXML(), SSDPCache::Find(), LogForwardThread::forwardMessage(), BaseRequestHandler::HandleAnnounce(), 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(), MythMainWindow::Init(), BackendSelection::Init(), UPnpCDSMusic::LoadAlbums(), UPnpCDSMusic::LoadArtists(), UPnpCDSTv::LoadChannels(), UPnpCDSTv::LoadDates(), UPnpCDSTv::LoadGenres(), UPnpCDSMusic::LoadGenres(), UPnpCDSVideo::LoadGenres(), UPnpCDSTv::LoadRecGroups(), UPnpCDSTv::LoadRecordings(), UPnpCDSVideo::LoadSeasons(), UPnpCDSVideo::LoadSeries(), UPnpCDSTv::LoadTitles(), UPnpCDSMusic::LoadTracks(), UPnpCDSVideo::LoadVideos(), LoggerThread::logConsole(), LogPrintLine(), Eventing::NotifySubscriber(), DVDRingBuffer::OpenFile(), RemoteFile::openSocket(), MetadataDownload::prependLookup(), DeleteThread::ProcessNew(), DeleteThread::ProcessOld(), SSDP::ProcessSearchRequest(), MainServer::reconnectTimeout(), HouseKeeper::RegisterTask(), AvFormatDecoderDVD::ReleaseContext(), RemoteGetFileList(), RemoteSendReceiveStringList(), SSDPCache::Remove(), SSDPCache::RemoveStale(), ProcessRequestRunnable::run(), MythSystemLegacySignalManager::run(), TaskQueue::run(), DBLoggerThread::run(), LoggerThread::run(), DVDRingBuffer::safe_read(), PlaybackSock::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), PlayerContext::SetTVChain(), SSDPCache::SSDPCache(), DVDRingBuffer::StartFromBeginning(), TVRec::StartRecording(), TVRec::StopLiveTV(), MythVDPAUPainter::Teardown(), MythD3D9Painter::Teardown(), telnet(), MythContextPrivate::UPnPautoconf(), MythSystemLegacy::~MythSystemLegacy(), PlaybackSock::~PlaybackSock(), RemoteFile::~RemoteFile(), SocketHandler::~SocketHandler(), SSDP::~SSDP(), UPnpCDSExtension::~UPnpCDSExtension(), VideoOutputOpenGL::~VideoOutputOpenGL(), 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

Definition at line 57 of file referencecounter.h.

Referenced by DecrRef(), IncrRef(), and ~ReferenceCounter().


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