CoreLinux++  0.4.32
SemaphoreGroup.hpp
1 #if !defined(__SEMAPHOREGROUP_HPP)
2 #define __SEMAPHOREGROUP_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(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 #if !defined(__SEMAPHORECOMMON_HPP)
29 #include <SemaphoreCommon.hpp>
30 #endif
31 
32 #if !defined(__ABSTRACTSEMAPHORE_HPP)
33 #include <AbstractSemaphore.hpp>
34 #endif
35 
36 #if !defined(__MAP_HPP)
37 #include <Map.hpp>
38 #endif
39 
40 
41 namespace corelinux
42 {
43  const Dword NAMEBUFFERSIZE(254);
44 
46  {
47  Int theCount;
48  AbstractSemaphorePtr theSem;
49  };
50 
51  CORELINUX_MAP( Index, SemaphoreReference, std::less<Index> , SemaphoreShares );
52 
53  DECLARE_CLASS( SemaphoreGroup );
54 
63  {
64  public:
65 
78  SemaphoreGroup( Short , Int Rights = OWNER_ALL )
80 
104  (
105  Short,
107  Int ,
109  ) throw(Assertion,SemaphoreException);
110 
133  (
134  Short,
135  CharCptr,
136  Int ,
138  ) throw(Assertion,SemaphoreException);
139 
140 
142 
143  virtual ~SemaphoreGroup( void );
144 
145  //
146  // Operator overloads
147  //
148 
155  bool operator==( SemaphoreGroupCref ) const;
156  //
157  // Accessors
158  //
164  Short getSemaphoreCount( void ) const;
165 
172  {
173  return theIdentifier;
174  }
175 
176  //
177  // Factory methods
178  //
179 
186  virtual AbstractSemaphorePtr createSemaphore( void )
187  throw( SemaphoreException ) = 0;
188 
206  virtual AbstractSemaphorePtr createSemaphore
207  (
208  SemaphoreIdentifierRef aIdentifier,
210  bool Recursive=false,
211  bool Balking = false
212  ) throw( SemaphoreException ) = 0;
213 
232  virtual AbstractSemaphorePtr createSemaphore
233  (
234  std::string aName,
236  bool Recursive=false,
237  bool Balking = false
238  ) throw( SemaphoreException ) = 0;
239 
247  virtual void destroySemaphore( AbstractSemaphorePtr )
248  throw( SemaphoreException ) = 0;
249  protected:
250 
251  //
252  // Constructors
253  //
255 
256  SemaphoreGroup( void ) throw( Assertion );
257 
259 
261  throw( Assertion );
262 
263  //
264  // Operator overloads
265  //
266 
268 
270  throw( Assertion );
271 
272  //
273  // Methods for shared control
274  //
275 
284  void setGroupType( IntCref ) const;
285 
293  //
294  // Methods for SemaphoreGroup base
295  //
296 
298 
299  inline bool isPrivate( void ) const
300  {
301  return (theGroupCSA == NULLPTR);
302  }
303 
304  protected:
305 
306  private:
307 
308  friend class SemaphoreCommon;
309 
311 
312  SemaphoreGroupIdentifier theIdentifier;
313 
315 
316  Short theNumberOfSemaphores;
317 
319 
320  CSAGrpHeaderPtr theGroupCSA;
321 
323 
324  Char theName[NAMEBUFFERSIZE];
325 
326  };
327 }
328 
329 #endif // if !defined(__SEMAPHOREGROUP_HPP)
330 
331 /*
332  Common rcs information do not modify
333  $Author: prudhomm $
334  $Revision: 1.9 $
335  $Date: 2000/08/31 22:52:20 $
336  $Locker: $
337 */
338 
Definition: SemaphoreGroup.hpp:45
Forward reference the various common classes.
Definition: AbstractAllocator.hpp:32
CreateDisposition
Creation dispositions for various system utilities.
Definition: AccessRights.hpp:63
The SemaphoreCommon manages the SemaphoreGroup common storage area.
Definition: SemaphoreCommon.hpp:89
Will throw exception if target exists.
Definition: AccessRights.hpp:71
ScalarIdentifier provides a templated interface for declaring CoreLinux Identifiers for simple scalar...
Definition: ScalarIdentifiers.hpp:37
Describes a CSA semaphore group.
Definition: SemaphoreCommon.hpp:48
A AbstractSemaphore supports the protocol that processes and/or threads agree to follow for the purpo...
Definition: AbstractSemaphore.hpp:85
SemaphoreGroupIdentifierCref getIdentifier(void) const
Return the SemaphoreGroupIdentifier.
Definition: SemaphoreGroup.hpp:171
Owner has read/write access.
Definition: AccessRights.hpp:43
SemaphoreException is the base exception type for Semaphore.
Definition: SemaphoreException.hpp:39
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
Will create or open.
Definition: AccessRights.hpp:67
A SemaphoreGroup is an extension to the Linux semaphore set.
Definition: SemaphoreGroup.hpp:62
bool isPrivate(void) const
Claim an unused semaphore from the group.
Definition: SemaphoreGroup.hpp:299

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