//%2005//////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation, The Open Group. // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // EMC Corporation; VERITAS Software Corporation; The Open Group. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //============================================================================== // // Author: Mike Brasher (mike-brasher@austin.rr.com) // //%///////////////////////////////////////////////////////////////////////////// #ifndef Pegasus_AtomicInt_h #define Pegasus_AtomicInt_h #include //#ifndef PEGASUS_INTERNALONLY //# error "ERROR: This header is for internal use only (AtomicInt.h)" //#endif PEGASUS_NAMESPACE_BEGIN template class AtomicIntTemplate { public: // Constructor. AtomicIntTemplate(Uint32 n = 0); // Destructor. ~AtomicIntTemplate(); // Sets value. void set(Uint32 n); // Gets value. Uint32 get() const; // Increment. void inc(); // Decrement. void dec(); // Decrements and returns true if it is zero. bool decAndTestIfZero(); // Assignment. AtomicIntTemplate& operator=(Uint32 n) { set(n); return* this; } // Post-increment. void operator++(int) { inc(); } // Post-decrement. void operator--(int) { dec(); } private: // Note: These methods are intentionally hidden (and should not be called). // The implementation is much easier without having to implement these for // every platform. AtomicIntTemplate(const AtomicIntTemplate&) { } AtomicIntTemplate& operator=(const AtomicIntTemplate&) { return *this; } Boolean operator==(Uint32) const { return false; } void operator++() { } void operator--() { } typedef AtomicIntTemplate This; ATOMIC_TYPE _rep; }; PEGASUS_NAMESPACE_END #if defined(PEGASUS_PLATFORM_LINUX_IX86_GNU) # include #elif defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) # include #elif defined(PEGASUS_PLATFORM_LINUX_PPC_GNU) # include #elif defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) # include #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) # include #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC) # include #else # include #endif PEGASUS_NAMESPACE_BEGIN typedef AtomicIntTemplate AtomicInt; PEGASUS_NAMESPACE_END #endif /* Pegasus_AtomicInt_h */