Added PSharedptr class
[pwlib.git] / samples / ThreadSafe / main.h
blob2cf2cd782a2580e72aaa61bceedf2f1d8d496c9a
1 /*
2 * main.h
4 * PWLib application header file for ThreadSafe
6 * Copyright 2002 Equivalence
8 * $Log$
9 * Revision 1.6 2003/10/27 22:12:56 dereksmithies
10 * Add more good changes to get Compare method work. Thanks to Gene Small
12 * Revision 1.5 2003/10/13 23:38:31 dereksmithies
13 * Add debugging statements, usage(), Fixed Compare method. Thanks Gene Small.
15 * Revision 1.4 2002/12/11 03:38:35 robertj
16 * Added more tests
18 * Revision 1.3 2002/12/02 01:08:29 robertj
19 * Updated to latest safe collection classes, thanks Vladimir Nesic
21 * Revision 1.2 2002/05/02 00:30:03 robertj
22 * Allowed for non-template containers
24 * Revision 1.1 2002/05/01 04:16:44 robertj
25 * Added thread safe collection classes.
29 #ifndef _ThreadSafe_MAIN_H
30 #define _ThreadSafe_MAIN_H
33 #include <ptlib/safecoll.h>
36 class ThreadSafe;
38 class TestObject : public PSafeObject
40 PCLASSINFO(TestObject, PSafeObject);
41 public:
42 TestObject(ThreadSafe & process, unsigned val);
43 ~TestObject();
45 Comparison Compare(const PObject & obj) const;
46 void PrintOn(ostream & strm) const;
48 ThreadSafe & process;
49 unsigned value;
53 class ThreadSafe : public PProcess
55 PCLASSINFO(ThreadSafe, PProcess)
57 public:
58 ThreadSafe();
59 ~ThreadSafe();
60 void Main();
62 private:
63 void Usage();
65 void Test1(PArgList & args);
66 void Test1Output();
67 void Test1OutputEnd();
68 PDECLARE_NOTIFIER(PThread, ThreadSafe, Test1Thread);
70 void Test2(PArgList & args);
71 PDECLARE_NOTIFIER(PThread, ThreadSafe, Test2Thread1);
72 PDECLARE_NOTIFIER(PThread, ThreadSafe, Test2Thread2);
74 void Test3(PArgList & args);
75 PDECLARE_NOTIFIER(PThread, ThreadSafe, Test3Thread1);
76 PDECLARE_NOTIFIER(PThread, ThreadSafe, Test3Thread2);
78 PSafeList<TestObject> unsorted;
79 PSafeSortedList<TestObject> sorted;
80 PSafeDictionary<POrdinalKey, TestObject> sparse;
82 PINDEX threadCount;
83 PTimeInterval startTick;
84 PMutex mutexObjects;
85 unsigned totalObjects;
86 unsigned currentObjects;
88 friend class TestObject;
92 #endif // _ThreadSafe_MAIN_H
95 // End of File ///////////////////////////////////////////////////////////////