stlab.adobe.com Adobe Systems Incorporated
counter.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /******************************************************************************/
8 
9 #ifndef ADOBE_COUNTER_HPP
10 #define ADOBE_COUNTER_HPP
11 
12 /******************************************************************************/
13 
14 #include <adobe/config.hpp>
15 
16 #include <boost/noncopyable.hpp>
17 
18 #include <adobe/implementation/atomic_primitives.hpp>
19 
20 /******************************************************************************/
21 
22 namespace adobe {
23 
24 /******************************************************************************/
25 
74 class counter_t
75 #if !defined(ADOBE_NO_DOCUMENTATION)
76  : boost::noncopyable
77 #endif
78 {
79 public:
81  {
82  count_m = implementation::atomic_t::value_type(1);
83  }
84 
85  void increment()
86  {
87  ++count_m;
88  }
89 
90  bool decrement()
91  {
92  return --count_m == implementation::atomic_t::value_type(0);
93  }
94 
95  bool is_one() const
96  {
97  return count_m == implementation::atomic_t::value_type(1);
98  }
99 
100 private:
101  implementation::atomic_t::type count_m;
102 };
103 
104 /******************************************************************************/
105 
106 } // namespace adobe
107 
108 /******************************************************************************/
109 // ADOBE_COUNTER_HPP
110 #endif
111 
112 /******************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google