PTLib  Version 2.18.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
safecoll.h File Reference
#include <ptlib/syncthrd.h>
Include dependency graph for safecoll.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  PSafeObject
 This class defines a thread-safe object in a collection. More...
 
class  PSafeLockBase
 
class  PSafeLockReadOnly
 Lock a PSafeObject for read only and automatically unlock it when go out of scope. More...
 
class  PSafeLockReadWrite
 Lock a PSafeObject for read/write and automatically unlock it when go out of scope. More...
 
class  PSafeCollection
 This class defines a thread-safe collection of objects. More...
 
class  PSafePtrBase
 This class defines a base class for thread-safe pointer to an object. More...
 
class  PSafePtrMultiThreaded
 This class defines a base class for thread-safe pointer to an object. More...
 
class  PSafePtr< T, BaseClass >
 This class defines a thread-safe enumeration of object in a collection. More...
 
class  PSafeColl< Coll, Base >
 This class defines a thread-safe collection of objects. More...
 
class  PSafeArray< Base >
 This class defines a thread-safe array of objects. More...
 
class  PSafeList< Base >
 This class defines a thread-safe list of objects. More...
 
class  PSafeSortedList< Base >
 This class defines a thread-safe sorted array of objects. More...
 
class  PSafeDictionaryBase< Coll, Key, Base >
 This class defines a thread-safe dictionary of objects. More...
 
class  PSafeDictionary< K, D >
 This class defines a thread-safe array of objects. More...
 
class  PSafeDictionary< K, D >::iterator_base
 
class  PSafeDictionary< K, D >::iterator_pair
 
class  PSafeDictionary< K, D >::iterator
 
class  PSafeDictionary< K, D >::const_iterator
 

Macros

#define P_INSTRUMENTED_LOCK_READ_ONLY2(var, obj)   PSafeLockReadOnly var((obj))
 
#define P_INSTRUMENTED_LOCK_READ_WRITE2(var, obj)   PSafeLockReadWrite var((obj))
 
#define P_MAKE_UNIQUE_VAR(base)   P_MAKE_UNIQUE_VAR1(base, __LINE__)
 
#define P_MAKE_UNIQUE_VAR1(base, line)   P_MAKE_UNIQUE_VAR2(base, line)
 
#define P_MAKE_UNIQUE_VAR2(base, line)   base##line
 
#define P_READ_WRITE_RETURN_ARG_0()
 
#define P_READ_WRITE_RETURN_ARG_1(arg)   ; if (!P_MAKE_UNIQUE_VAR(lock).IsLocked()) arg
 
#define P_READ_WRITE_RETURN_PART1(narg, args)   P_READ_WRITE_RETURN_PART2(narg, args)
 
#define P_READ_WRITE_RETURN_PART2(narg, args)   P_READ_WRITE_RETURN_ARG_##narg args
 
#define P_INSTRUMENTED_LOCK_READ_ONLY(...)   P_INSTRUMENTED_LOCK_READ_ONLY2(P_MAKE_UNIQUE_VAR(lock),*this) P_READ_WRITE_RETURN_PART1(PARG_COUNT(__VA_ARGS__), (__VA_ARGS__))
 
#define P_INSTRUMENTED_LOCK_READ_WRITE(...)   P_INSTRUMENTED_LOCK_READ_WRITE2(P_MAKE_UNIQUE_VAR(lock),*this) P_READ_WRITE_RETURN_PART1(PARG_COUNT(__VA_ARGS__), (__VA_ARGS__))
 

Enumerations

enum  PSafetyMode { PSafeReference, PSafeReadOnly, PSafeReadWrite }
 

Functions

template<class Base , class Derived >
PSafePtr< Derived > PSafePtrCast (const PSafePtr< Base > &oldPtr)
 Cast the pointer to a different type. More...
 

Macro Definition Documentation

#define P_INSTRUMENTED_LOCK_READ_ONLY (   ...)    P_INSTRUMENTED_LOCK_READ_ONLY2(P_MAKE_UNIQUE_VAR(lock),*this) P_READ_WRITE_RETURN_PART1(PARG_COUNT(__VA_ARGS__), (__VA_ARGS__))
#define P_INSTRUMENTED_LOCK_READ_ONLY2 (   var,
  obj 
)    PSafeLockReadOnly var((obj))
#define P_INSTRUMENTED_LOCK_READ_WRITE (   ...)    P_INSTRUMENTED_LOCK_READ_WRITE2(P_MAKE_UNIQUE_VAR(lock),*this) P_READ_WRITE_RETURN_PART1(PARG_COUNT(__VA_ARGS__), (__VA_ARGS__))
#define P_INSTRUMENTED_LOCK_READ_WRITE2 (   var,
  obj 
)    PSafeLockReadWrite var((obj))
#define P_MAKE_UNIQUE_VAR (   base)    P_MAKE_UNIQUE_VAR1(base, __LINE__)
#define P_MAKE_UNIQUE_VAR1 (   base,
  line 
)    P_MAKE_UNIQUE_VAR2(base, line)
#define P_MAKE_UNIQUE_VAR2 (   base,
  line 
)    base##line
#define P_READ_WRITE_RETURN_ARG_0 ( )
#define P_READ_WRITE_RETURN_ARG_1 (   arg)    ; if (!P_MAKE_UNIQUE_VAR(lock).IsLocked()) arg
#define P_READ_WRITE_RETURN_PART1 (   narg,
  args 
)    P_READ_WRITE_RETURN_PART2(narg, args)
#define P_READ_WRITE_RETURN_PART2 (   narg,
  args 
)    P_READ_WRITE_RETURN_ARG_##narg args

Enumeration Type Documentation

Enumerator
PSafeReference 
PSafeReadOnly 
PSafeReadWrite 

Function Documentation

template<class Base , class Derived >
PSafePtr<Derived> PSafePtrCast ( const PSafePtr< Base > &  oldPtr)

Cast the pointer to a different type.

The pointer being cast to MUST be a derived class or NULL is returned.