michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef BASE_ATOMIC_SEQUENCE_NUM_H_ michael@0: #define BASE_ATOMIC_SEQUENCE_NUM_H_ michael@0: michael@0: #include "base/atomicops.h" michael@0: #include "base/basictypes.h" michael@0: michael@0: namespace base { michael@0: michael@0: class AtomicSequenceNumber { michael@0: public: michael@0: AtomicSequenceNumber() : seq_(0) { } michael@0: explicit AtomicSequenceNumber(base::LinkerInitialized x) { /* seq_ is 0 */ } michael@0: michael@0: int GetNext() { michael@0: return static_cast( michael@0: base::subtle::NoBarrier_AtomicIncrement(&seq_, 1) - 1); michael@0: } michael@0: michael@0: private: michael@0: base::subtle::Atomic32 seq_; michael@0: DISALLOW_COPY_AND_ASSIGN(AtomicSequenceNumber); michael@0: }; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_ATOMIC_SEQUENCE_NUM_H_