safecoll.h
Go to the documentation of this file.
/*
* safecoll.h
*
* Thread safe collection classes.
*
* Portable Windows Library
*
* Copyright (c) 2002 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Contributor(s): ______________________________________.
*
* $Revision: 27948 $
* $Author: rjongbloed $
* $Date: 2012-06-30 22:54:23 -0500 (Sat, 30 Jun 2012) $
*/
#ifndef PTLIB_SAFE_COLLECTION_H
#define PTLIB_SAFE_COLLECTION_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
class PSafeObject : public PObject
{
PCLASSINFO(PSafeObject, PObject);
public:
PSafeObject(
PSafeObject * indirectLock = NULL
);
PBoolean SafeReference();
PBoolean SafeDereference();
PBoolean LockReadOnly() const;
void UnlockReadOnly() const;
PBoolean LockReadWrite();
void UnlockReadWrite();
void SafeRemove();
PBoolean SafelyCanBeDeleted() const;
virtual bool GarbageCollection();
private:
mutable PMutex safetyMutex;
unsigned safeReferenceCount;
bool safelyBeingRemoved;
PReadWriteMutex safeInUseMutex;
PReadWriteMutex * safeInUse;
friend class PSafeCollection;
};
class PSafeLockReadOnly
{
public:
PSafeLockReadOnly(const PSafeObject & object);
~PSafeLockReadOnly();
PBoolean Lock();
void Unlock();
PBoolean IsLocked() const { return locked; }
bool operator!() const { return !locked; }
protected:
PSafeObject & safeObject;
PBoolean locked;
};
class PSafeLockReadWrite
{
public:
PSafeLockReadWrite(const PSafeObject & object);
~PSafeLockReadWrite();
PBoolean Lock();
void Unlock();
PBoolean IsLocked() const { return locked; }
bool operator!() const { return !locked; }
protected:
PSafeObject & safeObject;
PBoolean locked;
};
class PSafeCollection : public PObject
{
PCLASSINFO(PSafeCollection, PObject);
public:
PSafeCollection(
PCollection * collection
);
~PSafeCollection();
protected:
virtual PBoolean SafeRemove(
PSafeObject * obj
);
virtual PBoolean SafeRemoveAt(
PINDEX idx
);
public:
virtual void RemoveAll(
PBoolean synchronous = false
);
void AllowDeleteObjects(
PBoolean yes = true
) { deleteObjects = yes; }
void DisallowDeleteObjects() { deleteObjects = false; }
virtual PBoolean DeleteObjectsToBeRemoved();
virtual void DeleteObject(PObject * object) const;
virtual void SetAutoDeleteObjects();
PINDEX GetSize() const;
PBoolean IsEmpty() const { return GetSize() == 0; }
const PMutex & GetMutex() const { return collectionMutex; }
protected:
void CopySafeCollection(PCollection * other);
void CopySafeDictionary(PAbstractDictionary * other);
void SafeRemoveObject(PSafeObject * obj);
PDECLARE_NOTIFIER(PTimer, PSafeCollection, DeleteObjectsTimeout);
PCollection * collection;
mutable PMutex collectionMutex;
bool deleteObjects;
PList<PSafeObject> toBeRemoved;
PMutex removalMutex;
PTimer deleteObjectsTimer;
private:
PSafeCollection(const PSafeCollection & other) : PObject(other) { }
void operator=(const PSafeCollection &) { }
friend class PSafePtrBase;
};
enum PSafetyMode {
PSafeReference,
PSafeReadOnly,
PSafeReadWrite
};
class PSafePtrBase : public PObject
{
PCLASSINFO(PSafePtrBase, PObject);
protected:
PSafePtrBase(
PSafeObject * obj = NULL,
PSafetyMode mode = PSafeReference
);
PSafePtrBase(
const PSafeCollection & safeCollection,
PSafetyMode mode,
PINDEX idx
);
PSafePtrBase(
const PSafeCollection & safeCollection,
PSafetyMode mode,
PSafeObject * obj
);
PSafePtrBase(
const PSafePtrBase & enumerator
);
public:
~PSafePtrBase();
virtual Comparison Compare(
const PObject & obj
) const;
virtual void PrintOn(
ostream &strm // Stream to print the object into.
) const;
virtual void SetNULL();
bool operator!() const { return currentObject == NULL; }
PSafetyMode GetSafetyMode() const { return lockMode; }
virtual PBoolean SetSafetyMode(
PSafetyMode mode
);
const PSafeCollection * GetCollection() const { return collection; }
virtual void Assign(const PSafePtrBase & ptr);
virtual void Assign(const PSafeCollection & safeCollection);
virtual void Assign(PSafeObject * obj);
virtual void Assign(PINDEX idx);
protected:
virtual void Next();
virtual void Previous();
virtual void DeleteObject(PSafeObject * obj);
enum EnterSafetyModeOption {
WithReference,
AlreadyReferenced
};
PBoolean EnterSafetyMode(EnterSafetyModeOption ref);
enum ExitSafetyModeOption {
WithDereference,
NoDereference
};
void ExitSafetyMode(ExitSafetyModeOption ref);
virtual void LockPtr() { }
virtual void UnlockPtr() { }
protected:
const PSafeCollection * collection;
PSafeObject * currentObject;
PSafetyMode lockMode;
};
class PSafePtrMultiThreaded : public PSafePtrBase
{
PCLASSINFO(PSafePtrMultiThreaded, PSafePtrBase);
protected:
PSafePtrMultiThreaded(
PSafeObject * obj = NULL,
PSafetyMode mode = PSafeReference
);
PSafePtrMultiThreaded(
const PSafeCollection & safeCollection,
PSafetyMode mode,
PINDEX idx
);
PSafePtrMultiThreaded(
const PSafeCollection & safeCollection,
PSafetyMode mode,
PSafeObject * obj
);
PSafePtrMultiThreaded(
const PSafePtrMultiThreaded & enumerator
);
public:
~PSafePtrMultiThreaded();
virtual Comparison Compare(
const PObject & obj
) const;
virtual void SetNULL();
virtual PBoolean SetSafetyMode(
PSafetyMode mode
);
virtual void Assign(const PSafePtrMultiThreaded & ptr);
virtual void Assign(const PSafePtrBase & ptr);
virtual void Assign(const PSafeCollection & safeCollection);
virtual void Assign(PSafeObject * obj);
virtual void Assign(PINDEX idx);
protected:
virtual void Next();
virtual void Previous();
virtual void DeleteObject(PSafeObject * obj);
virtual void LockPtr() { m_mutex.Wait(); }
virtual void UnlockPtr();
protected:
mutable PMutex m_mutex;
PSafeObject * m_objectToDelete;
};
template <class T, class BaseClass = PSafePtrBase> class PSafePtr : public BaseClass
{
public:
PSafePtr(
T * obj = NULL,
PSafetyMode mode = PSafeReference
) : BaseClass(obj, mode) { }
PSafePtr(
const PSafeCollection & safeCollection,
PSafetyMode mode = PSafeReadWrite,
PINDEX idx = 0
) : BaseClass(safeCollection, mode, idx) { }
PSafePtr(
const PSafeCollection & safeCollection,
PSafetyMode mode,
PSafeObject * obj
) : BaseClass(safeCollection, mode, obj) { }
PSafePtr(
const PSafePtr & ptr
) : BaseClass(ptr) { }
PSafePtr & operator=(const PSafePtr & ptr)
{
BaseClass::Assign(ptr);
return *this;
}
PSafePtr & operator=(const PSafeCollection & safeCollection)
{
BaseClass::Assign(safeCollection);
return *this;
}
PSafePtr & operator=(T * obj)
{
this->Assign(obj);
return *this;
}
PSafePtr & operator=(PINDEX idx)
{
BaseClass::Assign(idx);
return *this;
}
PSafePtr Set(T * obj)
{
this->LockPtr();
PSafePtr oldPtr = *this;
this->Assign(obj);
this->UnlockPtr();
return oldPtr;
}
operator T*() const { return (T *)BaseClass::currentObject; }
T & operator*() const { return *(T *)PAssertNULL(BaseClass::currentObject); }
T * operator->() const { return (T *)PAssertNULL(BaseClass::currentObject); }
T * operator++(int)
{
T * previous = (T *)BaseClass::currentObject;
BaseClass::Next();
return previous;
}
T * operator++()
{
BaseClass::Next();
return (T *)BaseClass::currentObject;
}
T * operator--(int)
{
T * previous = (T *)BaseClass::currentObject;
BaseClass::Previous();
return previous;
}
T * operator--()
{
BaseClass::Previous();
return (T *)BaseClass::currentObject;
}
};
template <class Base, class Derived>
PSafePtr<Derived> PSafePtrCast(const PSafePtr<Base> & oldPtr)
{
// return PSafePtr<Derived>::DownCast<Base>(oldPtr);
PSafePtr<Derived> newPtr;
Base * realPtr = oldPtr;
if (realPtr != NULL && PIsDescendant(realPtr, Derived))
newPtr.Assign(oldPtr);
return newPtr;
}
template <class Coll, class Base> class PSafeColl : public PSafeCollection
{
PCLASSINFO(PSafeColl, PSafeCollection);
public:
PSafeColl()
: PSafeCollection(new Coll)
{ }
PSafeColl(const PSafeColl & other)
: PSafeCollection(new Coll)
{
PWaitAndSignal lock2(other.collectionMutex);
CopySafeCollection(dynamic_cast<Coll *>(other.collection));
}
PSafeColl & operator=(const PSafeColl & other)
{
if (&other != this) {
RemoveAll(true);
PWaitAndSignal lock1(collectionMutex);
PWaitAndSignal lock2(other.collectionMutex);
CopySafeCollection(dynamic_cast<Coll *>(other.collection));
}
return *this;
}
virtual PSafePtr<Base> Append(
Base * obj,
PSafetyMode mode = PSafeReference
) {
PWaitAndSignal mutex(collectionMutex);
if (PAssert(collection->GetObjectsIndex(obj) == P_MAX_INDEX, "Cannot insert safe object twice") &&
obj->SafeReference())
return PSafePtr<Base>(*this, mode, collection->Append(obj));
return NULL;
}
virtual PBoolean Remove(
Base * obj
) {
return SafeRemove(obj);
}
virtual PBoolean RemoveAt(
PINDEX idx
) {
return SafeRemoveAt(idx);
}
virtual PSafePtr<Base> GetAt(
PINDEX idx,
PSafetyMode mode = PSafeReadWrite
) {
return PSafePtr<Base>(*this, mode, idx);
}
virtual PSafePtr<Base> FindWithLock(
const Base & value,
PSafetyMode mode = PSafeReadWrite
) {
collectionMutex.Wait();
PSafePtr<Base> ptr(*this, PSafeReference, collection->GetValuesIndex(value));
collectionMutex.Signal();
ptr.SetSafetyMode(mode);
return ptr;
}
};
template <class Base> class PSafeArray : public PSafeColl<PArray<Base>, Base>
{
public:
typedef PSafePtr<Base> value_type;
};
template <class Base> class PSafeList : public PSafeColl<PList<Base>, Base>
{
public:
typedef PSafePtr<Base> value_type;
};
template <class Base> class PSafeSortedList : public PSafeColl<PSortedList<Base>, Base>
{
public:
typedef PSafePtr<Base> value_type;
};
template <class Coll, class Key, class Base> class PSafeDictionaryBase : public PSafeCollection
{
PCLASSINFO(PSafeDictionaryBase, PSafeCollection);
public:
PSafeDictionaryBase()
: PSafeCollection(new Coll) { }
PSafeDictionaryBase(const PSafeDictionaryBase & other)
: PSafeCollection(new Coll)
{
PWaitAndSignal lock2(other.collectionMutex);
CopySafeDictionary(dynamic_cast<Coll *>(other.collection));
}
PSafeDictionaryBase & operator=(const PSafeDictionaryBase & other)
{
if (&other != this) {
RemoveAll(true);
PWaitAndSignal lock1(collectionMutex);
PWaitAndSignal lock2(other.collectionMutex);
CopySafeDictionary(dynamic_cast<Coll *>(other.collection));
}
return *this;
}
virtual void SetAt(const Key & key, Base * obj)
{
collectionMutex.Wait();
SafeRemove(((Coll *)collection)->GetAt(key));
if (PAssert(collection->GetObjectsIndex(obj) == P_MAX_INDEX, "Cannot insert safe object twice") &&
obj->SafeReference())
((Coll *)collection)->SetAt(key, obj);
collectionMutex.Signal();
}
virtual PBoolean RemoveAt(
const Key & key
) {
PWaitAndSignal mutex(collectionMutex);
return SafeRemove(((Coll *)collection)->GetAt(key));
}
virtual PBoolean Contains(
const Key & key
) {
PWaitAndSignal lock(collectionMutex);
return ((Coll *)collection)->Contains(key);
}
virtual PSafePtr<Base> GetAt(
PINDEX idx,
PSafetyMode mode = PSafeReadWrite
) {
return PSafePtr<Base>(*this, mode, idx);
}
virtual PSafePtr<Base> FindWithLock(
const Key & key,
PSafetyMode mode = PSafeReadWrite
) {
collectionMutex.Wait();
PSafePtr<Base> ptr(*this, PSafeReference, ((Coll *)collection)->GetAt(key));
collectionMutex.Signal();
ptr.SetSafetyMode(mode);
return ptr;
}
PArray<Key> GetKeys() const
{
PArray<Key> keys;
collectionMutex.Wait();
((Coll *)collection)->AbstractGetKeys(keys);
collectionMutex.Signal();
return keys;
}
};
template <class Key, class Base> class PSafeDictionary : public PSafeDictionaryBase<PDictionary<Key, Base>, Key, Base>
{
public:
typedef PSafePtr<Base> value_type;
};
#endif // PTLIB_SAFE_COLLECTION_H
// End Of File ///////////////////////////////////////////////////////////////
PSafePtr::operator++
T * operator++(int)
Post-increment the pointer.
Definition: safecoll.h:883
PSafeDictionaryBase::FindWithLock
virtual PSafePtr< Base > FindWithLock(const Key &key, PSafetyMode mode=PSafeReadWrite)
Find the instance in the collection of an object with the same value.
Definition: safecoll.h:1198
PSafeArray::value_type
PSafePtr< Base > value_type
Definition: safecoll.h:1069
PSafePtrMultiThreaded
This class defines a base class for thread-safe pointer to an object.
Definition: safecoll.h:614
PDECLARE_NOTIFIER
#define PDECLARE_NOTIFIER(notifier, notifiee, func)
Declare PNotifier derived class with INT parameter. Uses PDECLARE_NOTIFIER2 macro.
Definition: notifier.h:174
PWaitAndSignal
This class waits for the semaphore on construction and automatically signals the semaphore on destruc...
Definition: psync.h:86
PObject::Compare
virtual Comparison Compare(const PObject &obj) const
Compare the two objects and return their relative rank.
PSafeColl::Append
virtual PSafePtr< Base > Append(Base *obj, PSafetyMode mode=PSafeReference)
Add an object to the collection.
Definition: safecoll.h:992
PSafeObject::UnlockReadOnly
void UnlockReadOnly() const
Release the read only lock on an object.
PSafePtrBase::UnlockPtr
virtual void UnlockPtr()
Definition: safecoll.h:593
PSafePtrBase
This class defines a base class for thread-safe pointer to an object.
Definition: safecoll.h:460
PSafePtrBase::EnterSafetyModeOption
EnterSafetyModeOption
Definition: safecoll.h:580
PSafePtr
This class defines a thread-safe enumeration of object in a collection.
Definition: safecoll.h:742
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PSafePtrBase::currentObject
PSafeObject * currentObject
Definition: safecoll.h:597
PSafeDictionary
This class defines a thread-safe array of objects.
Definition: safecoll.h:1227
PSafeObject::SafeReference
PBoolean SafeReference()
Increment the reference count for object.
PSafeReference
Definition: safecoll.h:443
PSafeDictionaryBase::GetKeys
PArray< Key > GetKeys() const
Get an array containing all the keys for the dictionary.
Definition: safecoll.h:1211
PSafePtrMultiThreaded::m_objectToDelete
PSafeObject * m_objectToDelete
Definition: safecoll.h:718
PSafePtrBase::ExitSafetyModeOption
ExitSafetyModeOption
Definition: safecoll.h:586
PSafeLockReadOnly::safeObject
PSafeObject & safeObject
Definition: safecoll.h:286
PSafeLockReadOnly::IsLocked
PBoolean IsLocked() const
Definition: safecoll.h:282
PSafePtr::Set
PSafePtr Set(T *obj)
Set the safe pointer to the specified object.
Definition: safecoll.h:855
PSafeColl::PSafeColl
PSafeColl(const PSafeColl &other)
Copy constructor for safe collection.
Definition: safecoll.h:964
PSafePtrBase::GetCollection
const PSafeCollection * GetCollection() const
Get the associated collection this pointer may be contained in.
Definition: safecoll.h:567
PSafePtr::PSafePtr
PSafePtr(const PSafeCollection &safeCollection, PSafetyMode mode=PSafeReadWrite, PINDEX idx=0)
Create a new pointer to a PSafeObject.
Definition: safecoll.h:766
PSafeObject::LockReadOnly
PBoolean LockReadOnly() const
Lock the object for Read Only access.
PSafeObject::UnlockReadWrite
void UnlockReadWrite()
Release the read/write lock on an object.
PSafeObject::PSafeCollection
friend class PSafeCollection
Definition: safecoll.h:269
PSafeArray
This class defines a thread-safe array of objects.
Definition: safecoll.h:1066
PSafeList
This class defines a thread-safe list of objects.
Definition: safecoll.h:1077
PSafePtr::operator->
T * operator->() const
Allow access to the physical object the pointer is pointing to.
Definition: safecoll.h:877
PObject::Comparison
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:1184
PSafeDictionaryBase::SetAt
virtual void SetAt(const Key &key, Base *obj)
Add an object to the collection.
Definition: safecoll.h:1147
PSafeLockReadWrite::locked
PBoolean locked
Definition: safecoll.h:306
PAbstractDictionary
An abstract dictionary container.
Definition: dict.h:626
PSafeCollection::collectionMutex
PMutex collectionMutex
Definition: safecoll.h:428
PSafeDictionaryBase::PSafeDictionaryBase
PSafeDictionaryBase()
Create a safe dictionary wrapper around the real collection.
Definition: safecoll.h:1113
PSafeCollection::deleteObjects
bool deleteObjects
Definition: safecoll.h:429
PSafeLockReadOnly::locked
PBoolean locked
Definition: safecoll.h:287
PSafeObject::SafelyCanBeDeleted
PBoolean SafelyCanBeDeleted() const
Determine if the object can be safely deleted.
PSafeObject::SafeRemove
void SafeRemove()
Set the removed flag.
PSafeCollection
This class defines a thread-safe collection of objects.
Definition: safecoll.h:323
PIsDescendant
#define PIsDescendant(ptr, cls)
Definition: object.h:1065
PSafeColl::RemoveAt
virtual PBoolean RemoveAt(PINDEX idx)
Remove an object to the collection.
Definition: safecoll.h:1025
PSafeColl::Remove
virtual PBoolean Remove(Base *obj)
Remove an object to the collection.
Definition: safecoll.h:1011
PSafeCollection::toBeRemoved
PList< PSafeObject > toBeRemoved
Definition: safecoll.h:430
PSafeDictionaryBase::RemoveAt
virtual PBoolean RemoveAt(const Key &key)
Remove an object to the collection.
Definition: safecoll.h:1165
PSafeColl::operator=
PSafeColl & operator=(const PSafeColl &other)
Assign one safe collection to another.
Definition: safecoll.h:974
PList< PSafeObject >
PObject::PrintOn
virtual void PrintOn(ostream &strm) const
Output the contents of the object to the stream.
PTimer
A class representing a system timer.
Definition: timer.h:181
PSafePtrBase::LockPtr
virtual void LockPtr()
Definition: safecoll.h:592
PBoolean
BOOL PBoolean
Definition: object.h:102
PSafePtr::PSafePtr
PSafePtr(const PSafePtr &ptr)
Copy the pointer to the PSafeObject.
Definition: safecoll.h:790
PSafeCollection::GetMutex
const PMutex & GetMutex() const
Get the mutex for the collection.
Definition: safecoll.h:418
PSafeDictionaryBase
This class defines a thread-safe dictionary of objects.
Definition: safecoll.h:1105
PSafeCollection::collection
PCollection * collection
Definition: safecoll.h:427
PSafeCollection::removalMutex
PMutex removalMutex
Definition: safecoll.h:431
PSafePtr::PSafePtr
PSafePtr(const PSafeCollection &safeCollection, PSafetyMode mode, PSafeObject *obj)
Create a new pointer to a PSafeObject.
Definition: safecoll.h:779
PSafeDictionaryBase::GetAt
virtual PSafePtr< Base > GetAt(PINDEX idx, PSafetyMode mode=PSafeReadWrite)
Get the instance in the collection of the index.
Definition: safecoll.h:1186
PAssertNULL
#define PAssertNULL(ptr)
This macro is used to assert that a pointer must be non-null.
Definition: object.h:220
PSafeObject
This class defines a thread-safe object in a collection.
Definition: safecoll.h:119
PSafeReadWrite
Definition: safecoll.h:445
PSafePtrBase::WithReference
Definition: safecoll.h:581
PSafeCollection::deleteObjectsTimer
PTimer deleteObjectsTimer
Definition: safecoll.h:432
PSafePtr::operator=
PSafePtr & operator=(T *obj)
Set the new pointer to a PSafeObject.
Definition: safecoll.h:830
PSafeCollection::AllowDeleteObjects
void AllowDeleteObjects(PBoolean yes=true)
Disallow the automatic delete any objects that have been removed.
Definition: safecoll.h:380
PSafeColl::FindWithLock
virtual PSafePtr< Base > FindWithLock(const Base &value, PSafetyMode mode=PSafeReadWrite)
Find the instance in the collection of an object with the same value.
Definition: safecoll.h:1048
PSafePtrBase::operator!
bool operator!() const
Return true if pointer is NULL.
Definition: safecoll.h:549
PSafeDictionary::value_type
PSafePtr< Base > value_type
Definition: safecoll.h:1230
PSafePtrMultiThreaded::m_mutex
PMutex m_mutex
Definition: safecoll.h:717
PSafePtr::operator--
T * operator--(int)
Post-decrement the pointer.
Definition: safecoll.h:904
PSafeCollection::DisallowDeleteObjects
void DisallowDeleteObjects()
Disallow the automatic delete any objects that have been removed.
Definition: safecoll.h:388
PSafeLockReadWrite::safeObject
PSafeObject & safeObject
Definition: safecoll.h:305
PSafeColl
This class defines a thread-safe collection of objects.
Definition: safecoll.h:949
PSafeObject::GarbageCollection
virtual bool GarbageCollection()
Do any garbage collection that may be required by the object so that it may be finally deleted...
PSafePtrBase::WithDereference
Definition: safecoll.h:587
PSafePtr::operator=
PSafePtr & operator=(PINDEX idx)
Set the new pointer to a collection index.
Definition: safecoll.h:845
PSafeSortedList
This class defines a thread-safe sorted array of objects.
Definition: safecoll.h:1088
PSafetyMode
PSafetyMode
Definition: safecoll.h:442
PSafePtrMultiThreaded::LockPtr
virtual void LockPtr()
Definition: safecoll.h:713
PSafeCollection::IsEmpty
PBoolean IsEmpty() const
Determine if the collection is empty.
Definition: safecoll.h:414
PSafePtr::operator++
T * operator++()
Pre-increment the pointer.
Definition: safecoll.h:894
PSafePtrBase::GetSafetyMode
PSafetyMode GetSafetyMode() const
Get the locking mode used by this pointer.
Definition: safecoll.h:553
PSafePtrCast
PSafePtr< Derived > PSafePtrCast(const PSafePtr< Base > &oldPtr)
Cast the pointer to a different type.
Definition: safecoll.h:928
PSafeLockReadOnly::operator!
bool operator!() const
Definition: safecoll.h:283
PSafeLockReadWrite::operator!
bool operator!() const
Definition: safecoll.h:302
PArray
This template class maps the PArrayObjects to a specific object type.
Definition: array.h:1024
PMutex
Synonym for PTimedMutex.
PAssert
#define PAssert(b, msg)
This macro is used to assert that a condition must be true.
Definition: object.h:192
PSafePtr::operator=
PSafePtr & operator=(const PSafePtr &ptr)
Copy the pointer to the PSafeObject.
Definition: safecoll.h:799
PSafeLockReadWrite::IsLocked
PBoolean IsLocked() const
Definition: safecoll.h:301
PSafeColl::GetAt
virtual PSafePtr< Base > GetAt(PINDEX idx, PSafetyMode mode=PSafeReadWrite)
Get the instance in the collection of the index.
Definition: safecoll.h:1036
PReadWriteMutex
This class defines a thread synchronisation object.
Definition: syncthrd.h:251
PSafeSortedList::value_type
PSafePtr< Base > value_type
Definition: safecoll.h:1091
PSafePtrBase::collection
const PSafeCollection * collection
Definition: safecoll.h:596
PSafeObject::SafeDereference
PBoolean SafeDereference()
Decrement the reference count for object.
PSafePtr::operator--
T * operator--()
Pre-decrement the pointer.
Definition: safecoll.h:915
PSafeObject::PSafeObject
PSafeObject(PSafeObject *indirectLock=NULL)
Create a thread safe object.
PSafeLockReadOnly
Lock a PSafeObject for read only and automatically unlock it when go out of scope.
Definition: safecoll.h:275
PSafeReadOnly
Definition: safecoll.h:444
PSafePtr::operator*
T & operator*() const
Return the physical pointer to the object.
Definition: safecoll.h:873
PSafeDictionaryBase::PSafeDictionaryBase
PSafeDictionaryBase(const PSafeDictionaryBase &other)
Copy constructor for safe collection.
Definition: safecoll.h:1119
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PCollection
A collection is a container that collects together descendents of the PObject class.
Definition: contain.h:395
PSafeObject::LockReadWrite
PBoolean LockReadWrite()
Lock the object for Read/Write access.
PSafeList::value_type
PSafePtr< Base > value_type
Definition: safecoll.h:1080
PSafeLockReadWrite
Lock a PSafeObject for read/write and automatically unlock it when go out of scope.
Definition: safecoll.h:294
PSafeDictionaryBase::operator=
PSafeDictionaryBase & operator=(const PSafeDictionaryBase &other)
Assign one safe collection to another.
Definition: safecoll.h:1129
PSafeColl::PSafeColl
PSafeColl()
Create a safe list collection wrapper around the real collection.
Definition: safecoll.h:957
PSafePtr::operator=
PSafePtr & operator=(const PSafeCollection &safeCollection)
Start an enumerated PSafeObject.
Definition: safecoll.h:809
PSafeDictionaryBase::Contains
virtual PBoolean Contains(const Key &key)
Determine of the dictionary contains an entry for the key.
Definition: safecoll.h:1174
PSafePtrBase::lockMode
PSafetyMode lockMode
Definition: safecoll.h:598
PSafePtr::PSafePtr
PSafePtr(T *obj=NULL, PSafetyMode mode=PSafeReference)
Create a new pointer to a PSafeObject.
Definition: safecoll.h:754