1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_ATOMIC_SEQUENCE_NUM_H_ 6 #define BASE_ATOMIC_SEQUENCE_NUM_H_ 7 #pragma once 8 9 #include "base/atomicops.h" 10 #include "base/basictypes.h" 11 12 namespace base { 13 14 class AtomicSequenceNumber { 15 public: 16 AtomicSequenceNumber() : seq_(0) { } 17 explicit AtomicSequenceNumber(base::LinkerInitialized x) { /* seq_ is 0 */ } 18 19 int GetNext() { 20 return static_cast<int>( 21 base::subtle::NoBarrier_AtomicIncrement(&seq_, 1) - 1); 22 } 23 24 private: 25 base::subtle::Atomic32 seq_; 26 DISALLOW_COPY_AND_ASSIGN(AtomicSequenceNumber); 27 }; 28 29 } // namespace base 30 31 #endif // BASE_ATOMIC_SEQUENCE_NUM_H_ 32