Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

AbstractSemaphore.hpp

00001 #if   !defined(__ABSTRACTSEMAPHORE_HPP)
00002 #define  __ABSTRACTSEMAPHORE_HPP
00003 
00004 /*
00005   CoreLinux++ 
00006   Copyright (C) 1999,2000 CoreLinux Consortium
00007   
00008    The CoreLinux++ Library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public License as
00010    published by the Free Software Foundation; either version 2 of the
00011    License, or (at your option) any later version.
00012 
00013    The CoreLinux++ Library Library is distributed in the hope that it will 
00014    be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public
00019    License along with the GNU C Library; see the file COPYING.LIB.  If not,
00020    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021    Boston, MA 02111-1307, USA.  
00022 */
00023 
00024 #if !defined(__COMMON_HPP)
00025 #include <Common.hpp>
00026 #endif
00027 
00028 #if   !defined(__SEMAPHOREEXCEPTION_HPP)
00029 #include <SemaphoreException.hpp>
00030 #endif
00031 
00032 namespace   corelinux
00033 {
00034 
00039    enum SemaphoreOperationStatus
00040    {
00042 
00043       KERNELERROR=-1,
00044 
00046 
00047       SUCCESS=0,
00048 
00050 
00051       BALKED,
00052 
00054 
00055       TIMEDOUT,
00056 
00058 
00059       UNAVAILABLE
00060    };
00061 
00062    DECLARE_CLASS( SemaphoreGroup );
00063    DECLARE_CLASS( AbstractSemaphore );
00064 
00085    class AbstractSemaphore : public Synchronized
00086    {
00087 
00088    public:
00089 
00090 
00091       //
00092       // Constructors and destructors
00093       //
00094 
00099                            AbstractSemaphore
00100                               ( 
00101                                  SemaphoreGroupPtr, 
00102                                  SemaphoreIdentifierRef 
00103                               )
00104                               throw ( NullPointerException );
00105 
00107 
00108       virtual              ~AbstractSemaphore( void );
00109 
00110       //
00111       // Operator overloads
00112       //
00114 
00115                bool     operator==( AbstractSemaphoreCref aRef ) const;
00116 
00117       //
00118       // Accessors
00119       //
00120 
00122 
00123       virtual  bool  isBalkingEnabled( void ) const = 0;
00124 
00126 
00127       virtual  bool  isRecursionEnabled( void ) const = 0;
00128 
00130 
00131                SemaphoreIdentifierCref    getIdentifier( void ) const ;
00132 
00134 
00135                SemaphoreGroupIdentifierCref  getGroupIdentifier( void ) const;
00136 
00138 
00139       virtual  ThreadIdentifierCref getOwningThreadIdentifier( void ) 
00140                                                       const = 0;
00141 
00143 
00144       virtual  CounterCref    getRecursionQueueLength( void ) const = 0;
00145 
00147 
00148                Int   getValue( void );
00149 
00151 
00152                Int   getInitialValue( void );
00153 
00155 
00156       virtual  bool  isLocked( void ) = 0;
00157 
00158 
00159       //
00160       // Mutators
00161       //
00162 
00164 
00165       virtual  SemaphoreOperationStatus   lockWithWait( void ) 
00166                      throw(SemaphoreException) = 0;
00167 
00169 
00170       virtual  SemaphoreOperationStatus   lockWithNoWait( void )
00171                      throw(SemaphoreException) = 0;
00172 
00174 
00175 //      virtual  SemaphoreOperationStatus   lockWithTimeOut( Timer ) 
00176 //                   throw(SemaphoreException) = 0;
00177 
00179 
00180       virtual  SemaphoreOperationStatus   release( void ) 
00181                      throw(SemaphoreException) = 0;
00182 
00183 
00184    protected:
00185 
00186       //
00187       // Constructors
00188       //
00189 
00190                            AbstractSemaphore( AbstractSemaphoreCref ) 
00191                               throw(Assertion);
00192 
00193       //
00194       // Operator overloads
00195       //
00196                AbstractSemaphoreRef operator=( AbstractSemaphoreCref ) 
00197                               throw(Assertion);
00198 
00199       //
00200       // Accessors
00201       //
00202 
00204 
00205       inline   SemaphoreIdentifierRef   getId( void ) 
00206                {
00207                   return theSemIdentifier;
00208                }
00209 
00210 
00212 
00213       inline   Int   getGroupId( void ) const
00214                {
00215                   return theGroupIdentifier;
00216                }
00217 
00219 
00220       virtual  ThreadIdentifierRef  getOwnerId( void ) = 0;
00221 
00222 
00223 
00224       //
00225       // Mutators
00226       //
00228 
00229                SemaphoreOperationStatus   setLock( Int );
00230 
00232 
00233                SemaphoreOperationStatus   setUnlock( Int );
00234 
00236 
00237                SemaphoreOperationStatus   setValue( Int );
00238 
00239 
00240    private:
00241 
00243 
00244                SemaphoreGroupPtr    theGroup;
00245 
00247 
00248                Int   theGroupIdentifier;
00249 
00251 
00252                SemaphoreIdentifier  theSemIdentifier;
00253 
00254    };
00255 }
00256 
00257 #endif // if !defined(__ABSTRACTSEMAPHORE_HPP)
00258 
00259 /*
00260    Common rcs information do not modify
00261    $Author: frankc $
00262    $Revision: 1.4 $
00263    $Date: 2000/07/28 01:37:09 $
00264    $Locker:  $
00265 */
00266 
00267 
00268 
00269 

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