Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
counter.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/******************************************************************************/
7
8#ifndef ADOBE_COUNTER_HPP
9#define ADOBE_COUNTER_HPP
10
11/******************************************************************************/
12
13#include <adobe/config.hpp>
14
15#include <boost/noncopyable.hpp>
16
17#include <adobe/implementation/atomic_primitives.hpp>
18
19/******************************************************************************/
20
21namespace adobe {
22
23/******************************************************************************/
24
47
53
59
68
76
77
79#if !defined(ADOBE_NO_DOCUMENTATION)
80 : boost::noncopyable
81#endif
82{
83public:
84 counter_t() { count_m = implementation::atomic_t::value_type(1); }
85
86 void increment() { ++count_m; }
87
88 bool decrement() { return --count_m == implementation::atomic_t::value_type(0); }
89
90 bool is_one() const { return count_m == implementation::atomic_t::value_type(1); }
91
92private:
93 implementation::atomic_t::type count_m;
94};
95
96/******************************************************************************/
97
98} // namespace adobe
99
100/******************************************************************************/
101// ADOBE_COUNTER_HPP
102#endif
103
104/******************************************************************************/
bool is_one() const
Definition counter.hpp:90