(file) Return to AtomicInt.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 mike  1.1.2.1 //%2005////////////////////////////////////////////////////////////////////////
  2               //
  3               // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4               // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5               // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6               // IBM Corp.; EMC Corporation, The Open Group.
  7               // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8               // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9               // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10               // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11               //
 12               // Permission is hereby granted, free of charge, to any person obtaining a copy
 13               // of this software and associated documentation files (the "Software"), to
 14               // deal in the Software without restriction, including without limitation the
 15               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 16               // sell copies of the Software, and to permit persons to whom the Software is
 17               // furnished to do so, subject to the following conditions:
 18               //
 19               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 20               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 21               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 22 mike  1.1.2.1 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 23               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 24               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 25               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 26               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27               //
 28               //==============================================================================
 29               //
 30               // Author: Mike Brasher (mbrasher@austin.rr.com)
 31               //
 32               //%/////////////////////////////////////////////////////////////////////////////
 33               
 34               #ifndef Pegasus_AtomicInt_h
 35               #define Pegasus_AtomicInt_h
 36               
 37               #include <Pegasus/Common/Config.h>
 38               
 39               #ifndef PEGASUS_INTERNALONLY
 40               # error "ERROR: This header is for internal use only (AtomicInt.h)"
 41               #endif
 42               
 43 mike  1.1.2.1 PEGASUS_NAMESPACE_BEGIN
 44               
 45               template<class ATOMIC_TYPE>
 46               class AtomicIntTemplate
 47               {
 48               public:
 49               
 50                   // Constructor.
 51                   AtomicIntTemplate(Uint32 n = 0);
 52               
 53                   // Destructor.
 54                   ~AtomicIntTemplate();
 55               
 56                   // Sets value.
 57                   void set(Uint32 n);
 58               
 59                   // Gets value.
 60                   Uint32 get() const;
 61               
 62                   // Increment.
 63                   void inc();
 64 mike  1.1.2.1 
 65                   // Decrement.
 66                   void dec();
 67               
 68                   // Decrements and returns true if it is zero.
 69                   bool dec_and_test();
 70               
 71                   // Assignment.
 72                   AtomicIntTemplate& operator=(Uint32 n) { set(n); }
 73               
 74                   // Post-increment.
 75                   void operator++(int) { inc(); }
 76               
 77                   // Post-decrement.
 78                   void operator--(int) { dec(); }
 79               
 80               private:
 81               
 82                   // Note: These methods are intentionally hidden (and should not be called).
 83                   // The implementation is much easier without having to implement these for
 84                   // every platform.
 85 mike  1.1.2.1     AtomicIntTemplate(const AtomicIntTemplate&) { }
 86                   AtomicIntTemplate& operator=(const AtomicIntTemplate&) { return *this; }
 87                   Boolean operator==(Uint32) const { return false; }
 88                   void operator++() { }
 89                   void operator--() { }
 90               
 91                   typedef AtomicIntTemplate<ATOMIC_TYPE> This;
 92               
 93                   ATOMIC_TYPE _rep;
 94               };
 95               
 96               PEGASUS_NAMESPACE_END
 97               
 98               #if defined(PEGASUS_PLATFORM_LINUX_IX86_GNU)
 99 mike  1.1.2.3 # include <Pegasus/Common/AtomicInt_LINUX_IX86_GNU.h>
100 mike  1.1.2.1 #elif defined(PEGASUS_PLATFORM_LINUX_PPC_GNU)
101 mike  1.1.2.3 # include <Pegasus/Common/AtomicInt_LINUX_PPC_GNU.h>
102 mike  1.1.2.1 #elif defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
103 mike  1.1.2.3 # include <Pegasus/Common/AtomicInt_WIN32_IX86_MSVC.h>
104 mike  1.1.2.1 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
105 mike  1.1.2.3 # include <Pegasus/Common/AtomicInt_ZOS_ZSERIES_IBM.h>
106 mike  1.1.2.1 #else
107 mike  1.1.2.3 # include <Pegasus/Common/AtomicInt_Generic.h>
108 mike  1.1.2.1 #endif
109               
110               PEGASUS_NAMESPACE_BEGIN
111               
112               typedef AtomicIntTemplate<AtomicType> NewAtomicInt;
113               
114               PEGASUS_NAMESPACE_END
115               
116               #endif /* Pegasus_AtomicInt_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2