1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/*
* main.h
*
* PWLib application header file for ThreadSafe
*
* Copyright 2002 Equivalence
*
* $Revision: 20385 $
* $Author: rjongbloed $
* $Date: 2008-06-04 05:40:38 -0500 (Wed, 04 Jun 2008) $
*/
#ifndef _ThreadSafe_MAIN_H
#define _ThreadSafe_MAIN_H
#include <ptlib/pprocess.h>
#include <ptlib/safecoll.h>
class ThreadSafe;
class TestObject : public PSafeObject
{
PCLASSINFO(TestObject, PSafeObject);
public:
TestObject(ThreadSafe & process, unsigned val);
~TestObject();
Comparison Compare(const PObject & obj) const;
void PrintOn(ostream & strm) const;
ThreadSafe & process;
unsigned value;
};
class ThreadSafe : public PProcess
{
PCLASSINFO(ThreadSafe, PProcess)
public:
ThreadSafe();
~ThreadSafe();
void Main();
private:
void Usage();
void Test1(PArgList & args);
void Test1Output();
void Test1OutputEnd();
PDECLARE_NOTIFIER(PThread, ThreadSafe, Test1Thread);
void Test2(PArgList & args);
PDECLARE_NOTIFIER(PThread, ThreadSafe, Test2Thread1);
PDECLARE_NOTIFIER(PThread, ThreadSafe, Test2Thread2);
void Test3(PArgList & args);
PDECLARE_NOTIFIER(PThread, ThreadSafe, Test3Thread1);
PDECLARE_NOTIFIER(PThread, ThreadSafe, Test3Thread2);
PSafeList<TestObject> unsorted;
PSafeSortedList<TestObject> sorted;
PSafeDictionary<POrdinalKey, TestObject> sparse;
PINDEX threadCount;
PTimeInterval startTick;
PMutex mutexObjects;
unsigned totalObjects;
unsigned currentObjects;
friend class TestObject;
};
#endif // _ThreadSafe_MAIN_H
// End of File ///////////////////////////////////////////////////////////////
|