00001
#if !defined(__SYNCHRONIZED_HPP)
00002
#define __SYNCHRONIZED_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#if !defined IN_COMMON_HPP
00025
#error Synchronized.hpp is included by Common.hpp only.
00026
#endif
00027
00028
#if !defined(__SEMAPHOREEXCEPTION_HPP)
00029
#include <SemaphoreException.hpp>
00030
#endif
00031
00032
namespace corelinux
00033 {
00034 DECLARE_CLASS( Synchronized );
00035
00041 class Synchronized
00042 {
00043
protected:
00044
00045 DECLARE_CLASS(
Guard );
00046
00053 class Guard
00054 {
00055
00056
public:
00057
00059
00060
Guard(
GuardCref );
00061
00062
00064
00065
~Guard(
void );
00066
00067
00068
00069
00070
00071
00073
00074
void release(
void );
00075
00076
protected:
00077
00078
friend class Synchronized;
00079
00081
00082
Guard(
SynchronizedPtr );
00083
00085
00086
Guard(
void );
00087
00089
00090
GuardRef operator=(
GuardCref );
00091
00092
private:
00093
00095
00096
mutable SynchronizedPtr theSynchronized;
00097 };
00098
00099
public:
00100
00101
00102
00103
00104
00106
00107
Synchronized(
void );
00108
00110
00111
Synchronized(
SynchronizedCref );
00112
00114
00115
virtual ~Synchronized(
void );
00116
00117
00118
00119
00120
00122
00123
SynchronizedRef operator=(
SynchronizedCref );
00124
00126
00127
bool operator==(
SynchronizedCref ) const;
00128
00129 protected:
00130
00131
00132
00133
00134
00141
Guard access(
void ) const throw(
SemaphoreException) ;
00142
00143
00144 };
00145
00146 #define GUARD \
00147
Guard aGuardedLock( this->access() )
00148 }
00149
00150
00151 #endif
00152
00153
00154
00155
00156
00157
00158
00159
00160