CppUnit project page FAQ CppUnit home page

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SynchronizedObject.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_SYNCHRONIZEDOBJECT_H
00002 #define CPPUNIT_SYNCHRONIZEDOBJECT_H
00003 
00004 #include <cppunit/Portability.h>
00005 
00006 
00007 CPPUNIT_NS_BEGIN
00008 
00009 
00022 class CPPUNIT_API SynchronizedObject
00023 {
00024 public:
00027   class SynchronizationObject
00028   {
00029     public:
00030       SynchronizationObject() {}
00031       virtual ~SynchronizationObject() {}
00032 
00033       virtual void lock() {}
00034       virtual void unlock() {}
00035   };
00036 
00039   SynchronizedObject( SynchronizationObject *syncObject =0 );
00040 
00042   virtual ~SynchronizedObject();
00043 
00044 protected:
00047   class ExclusiveZone
00048   {
00049     SynchronizationObject *m_syncObject;
00050 
00051   public:
00052     ExclusiveZone( SynchronizationObject *syncObject ) 
00053         : m_syncObject( syncObject ) 
00054     { 
00055       m_syncObject->lock(); 
00056     }
00057 
00058     ~ExclusiveZone() 
00059     { 
00060       m_syncObject->unlock (); 
00061     }
00062   };
00063 
00064   virtual void setSynchronizationObject( SynchronizationObject *syncObject );
00065 
00066 protected:
00067   SynchronizationObject *m_syncObject;
00068 
00069 private:
00071   SynchronizedObject( const SynchronizedObject &copy );
00072 
00074   void operator =( const SynchronizedObject &copy );
00075 };
00076 
00077 
00078 CPPUNIT_NS_END
00079 
00080 #endif  // CPPUNIT_SYNCHRONIZEDOBJECT_H

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers