blob: 11805a0ae501b37207342dd33fae76604569baae [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.
[email protected]611dbe02008-08-05 09:57:364
5#ifndef BASE_ATOMIC_SEQUENCE_NUM_H_
6#define BASE_ATOMIC_SEQUENCE_NUM_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]611dbe02008-08-05 09:57:368
9#include "base/atomicops.h"
10#include "base/basictypes.h"
11
12namespace base {
13
14class AtomicSequenceNumber {
15 public:
16 AtomicSequenceNumber() : seq_(0) { }
[email protected]a10a16b2008-09-02 13:11:4617 explicit AtomicSequenceNumber(base::LinkerInitialized x) { /* seq_ is 0 */ }
[email protected]611dbe02008-08-05 09:57:3618
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_