vdr 2.7.5
cListBase Class Reference

#include <tools.h>

Public Member Functions

virtual ~cListBase ()
bool Lock (cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
void SetSyncStateKey (cStateKey &StateKey)
void SetUseGarbageCollector (void)
void SetExplicitModify (void)
void SetModified (void)
void Add (cListObject *Object, cListObject *After=NULL)
void Ins (cListObject *Object, cListObject *Before=NULL)
void Del (cListObject *Object, bool DeleteObject=true)
virtual void Move (int From, int To)
void Move (cListObject *From, cListObject *To)
virtual void Clear (void)
bool Contains (const cListObject *Object) const
const cListObjectGet (int Index) const
cListObjectGet (int Index)
int Count (void) const
void Sort (void)

Protected Member Functions

 cListBase (const char *NeedsLocking=NULL)

Protected Attributes

cListObjectobjects
cListObjectlastObject
int count
cStateLock stateLock
const char * needsLocking
bool useGarbageCollector

Detailed Description

Definition at line 564 of file tools.h.

Constructor & Destructor Documentation

◆ cListBase()

cListBase::cListBase ( const char * NeedsLocking = NULL)
protected

Definition at line 2152 of file tools.c.

References count, lastObject, needsLocking, objects, stateLock, and useGarbageCollector.

Referenced by cList< T >::cList(), and Get().

◆ ~cListBase()

cListBase::~cListBase ( )
virtual

Definition at line 2161 of file tools.c.

References Clear().

Member Function Documentation

◆ Add()

◆ Clear()

◆ Contains()

bool cListBase::Contains ( const cListObject * Object) const

If a pointer to an object contained in this list has been obtained while holding a lock, and that lock has been released, but the pointer is kept for later use (after obtaining a new lock), Contains() can be called with that pointer to make sure the object it points to is still part of this list (it may have been deleted or otherwise removed from the list after the lock during which the pointer was initially retrieved has been released).

Definition at line 2263 of file tools.c.

References objects.

Referenced by cMenuChannels::Delete().

◆ Count()

◆ Del()

◆ Get() [1/2]

cListObject * cListBase::Get ( int Index)
inline

Definition at line 626 of file tools.h.

References cListBase().

◆ Get() [2/2]

const cListObject * cListBase::Get ( int Index) const

Definition at line 2282 of file tools.c.

References objects.

Referenced by cList< T >::Get(), and Move().

◆ Ins()

void cListBase::Ins ( cListObject * Object,
cListObject * Before = NULL )

◆ Lock()

bool cListBase::Lock ( cStateKey & StateKey,
bool Write = false,
int TimeoutMs = 0 ) const

Tries to get a lock on this list and returns true if successful.

By default a read lock is requested. Set Write to true to obtain a write lock. If TimeoutMs is not zero, it waits for the given number of milliseconds before giving up. If you need to lock more than one list at the same time, make sure you set TimeoutMs to a suitable value in all of the calls to Lock(), and be prepared to handle situations where you do not get all of the requested locks. In such cases you should release all the locks you have obtained so far and try again. StateKey.TimedOut() tells you whether the lock attempt failed due to a timeout or because the state of the lock hasn't changed since the previous locking attempt. To implicitly avoid deadlocks when locking more than one of the global lists of VDR at the same time, make sure you always lock Timers, Channels, Recordings and Schedules in this sequence. You may keep pointers to objects in this list, even after releasing the lock. However, you may only access such objects if you are holding a proper lock again. If an object has been deleted from the list while you did not hold a lock (for instance by an other thread), the object will still be there, but no longer within this list (it is then stored in the ListGarbageCollector). That way even if you access the object after it has been deleted, you won't cause a segfault. You can call the Contains() function to check whether an object you are holding a pointer to is still in the list. Note that the garbage collector is purged when the usual housekeeping is done.

Definition at line 2166 of file tools.c.

References esyslog, needsLocking, and stateLock.

Referenced by cVideoDirectoryScannerThread::ScanVideoDir().

◆ Move() [1/2]

void cListBase::Move ( cListObject * From,
cListObject * To )

◆ Move() [2/2]

void cListBase::Move ( int From,
int To )
virtual

Reimplemented in cMenuChannels.

Definition at line 2223 of file tools.c.

References Get(), and Move().

Referenced by Move(), cMenuChannels::Move(), and cOsdMenu::ProcessKey().

◆ SetExplicitModify()

void cListBase::SetExplicitModify ( void )

If you have obtained a write lock on this list, and you don't want it to be automatically marked as modified when the lock is released, a call to this function will disable this, and you can explicitly call SetModified() to have the list marked as modified.

Definition at line 2272 of file tools.c.

References stateLock.

Referenced by cMenuRecordings::Delete().

◆ SetModified()

void cListBase::SetModified ( void )

Unconditionally marks this list as modified.

Definition at line 2277 of file tools.c.

References stateLock.

Referenced by cRecordingsHandlerEntry::Active(), cRecordingsHandlerEntry::Cleanup(), cRecordControl::cRecordControl(), and cMenuRecordings::Delete().

◆ SetSyncStateKey()

void cListBase::SetSyncStateKey ( cStateKey & StateKey)
inline

When making changes to this list (while holding a write lock) that shall not affect some other code that reacts to such changes, this function can be called with the StateKey used by that other code.

See cStateLock::SetSyncStateKey() for details.

Definition at line 599 of file tools.h.

References stateLock.

Referenced by cMenuTimers::Delete(), main(), and cMenuTimers::OnOff().

◆ SetUseGarbageCollector()

void cListBase::SetUseGarbageCollector ( void )
inline

Definition at line 604 of file tools.h.

References useGarbageCollector.

◆ Sort()

Member Data Documentation

◆ count

int cListBase::count
protected

Definition at line 567 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Count(), Del(), cOsdMenu::Del(), cOsdMenu::Display(), Ins(), and Sort().

◆ lastObject

cListObject * cListBase::lastObject
protected

Definition at line 566 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Del(), Ins(), cList< T >::Last(), Move(), and Sort().

◆ needsLocking

const char* cListBase::needsLocking
protected

Definition at line 569 of file tools.h.

Referenced by cListBase(), and Lock().

◆ objects

cListObject* cListBase::objects
protected

Definition at line 566 of file tools.h.

Referenced by Add(), Clear(), cListBase(), Contains(), Del(), cList< T >::First(), Get(), Ins(), Move(), and Sort().

◆ stateLock

cStateLock cListBase::stateLock
mutableprotected

Definition at line 568 of file tools.h.

Referenced by cListBase(), Lock(), SetExplicitModify(), SetModified(), and SetSyncStateKey().

◆ useGarbageCollector

bool cListBase::useGarbageCollector
protected

Definition at line 570 of file tools.h.

Referenced by cListBase(), Del(), and SetUseGarbageCollector().


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