CoreLinux++  0.4.32
Synchronized.hpp
1 #if !defined(__SYNCHRONIZED_HPP)
2 #define __SYNCHRONIZED_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 1999,2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined IN_COMMON_HPP
25  #error Synchronized.hpp is included by Common.hpp only.
26 #endif
27 
28 #if !defined(__SEMAPHOREEXCEPTION_HPP)
29 #include <SemaphoreException.hpp>
30 #endif
31 
32 namespace corelinux
33 {
34  DECLARE_CLASS( Synchronized );
35 
42  {
43  protected:
44 
45  DECLARE_CLASS( Guard );
46 
53  class Guard
54  {
55 
56  public:
57 
59 
60  Guard( GuardCref );
61 
62 
64 
65  ~Guard( void );
66 
67 
68  //
69  // Mutator
70  //
71 
73 
74  void release( void );
75 
76  protected:
77 
78  friend class Synchronized;
79 
81 
83 
85 
86  Guard( void );
87 
89 
91 
92  private:
93 
95 
96  mutable SynchronizedPtr theSynchronized;
97  };
98 
99  public:
100 
101  //
102  // Constructors and destructor
103  //
104 
106 
107  Synchronized( void );
108 
110 
112 
114 
115  virtual ~Synchronized( void );
116 
117  //
118  // Operator overloads
119  //
120 
122 
124 
126 
127  bool operator==( SynchronizedCref ) const;
128 
129  protected:
130 
131  //
132  // Mutators
133  //
134 
141  Guard access( void ) const throw(SemaphoreException) ;
142 
143 
144  };
145 
146 #define GUARD \
147  Guard aGuardedLock( this->access() )
148 }
149 
150 
151 #endif // if !defined(__SYNCHRONIZED_HPP)
152 
153 /*
154  Common rcs information do not modify
155  $Author: prudhomm $
156  $Revision: 1.4 $
157  $Date: 2000/08/31 22:52:20 $
158  $Locker: $
159 */
160 
Guard is the automatic instance that insures a lock is not held beyond the scope where it was instant...
Definition: Synchronized.hpp:53
Guard access(void) const
Access returns a instance of Guard which is block scoped to the caller.
Definition: Synchronized.cpp:84
GuardRef operator=(GuardCref)
Assignment operator never called.
Definition: Synchronized.cpp:128
void release(void)
Releases before destruction.
Definition: Synchronized.cpp:144
bool operator==(SynchronizedCref) const
Equality operator.
Definition: Synchronized.cpp:75
Guard(void)
Default constructor never called.
Definition: Synchronized.cpp:94
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
virtual ~Synchronized(void)
Virtual Destructor.
Definition: Synchronized.cpp:57
SemaphoreException is the base exception type for Semaphore.
Definition: SemaphoreException.hpp:39
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
~Guard(void)
Destructor.
Definition: Synchronized.cpp:139

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium