ipc/chromium/src/base/atomic_sequence_num.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/atomic_sequence_num.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_ATOMIC_SEQUENCE_NUM_H_
     1.9 +#define BASE_ATOMIC_SEQUENCE_NUM_H_
    1.10 +
    1.11 +#include "base/atomicops.h"
    1.12 +#include "base/basictypes.h"
    1.13 +
    1.14 +namespace base {
    1.15 +
    1.16 +class AtomicSequenceNumber {
    1.17 + public:
    1.18 +  AtomicSequenceNumber() : seq_(0) { }
    1.19 +  explicit AtomicSequenceNumber(base::LinkerInitialized x) { /* seq_ is 0 */ }
    1.20 +
    1.21 +  int GetNext() {
    1.22 +    return static_cast<int>(
    1.23 +        base::subtle::NoBarrier_AtomicIncrement(&seq_, 1) - 1);
    1.24 +  }
    1.25 +
    1.26 + private:
    1.27 +  base::subtle::Atomic32 seq_;
    1.28 +  DISALLOW_COPY_AND_ASSIGN(AtomicSequenceNumber);
    1.29 +};
    1.30 +
    1.31 +}  // namespace base
    1.32 +
    1.33 +#endif  // BASE_ATOMIC_SEQUENCE_NUM_H_

mercurial