FastUIDraw
reference_count_non_concurrent.hpp
Go to the documentation of this file.
1 /*!
2  * \file reference_count_non_concurrent.hpp
3  * \brief file reference_count_non_concurrent.hpp
4  *
5  * Copyright 2016 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 
20 #ifndef FASTUIDRAW_REFERENCE_COUNT_NON_CONCURRENT_HPP
21 #define FASTUIDRAW_REFERENCE_COUNT_NON_CONCURRENT_HPP
22 
23 #include <fastuidraw/util/util.hpp>
24 
25 namespace fastuidraw
26 {
27 
28 /*!\addtogroup Utility
29  * @{
30  */
31  /*!
32  * \brief
33  * Reference counter that is NOT thread safe
34  */
36  {
37  public:
38  /*!
39  * Initializes the counter as zero.
40  */
42  m_reference_count(0)
43  {}
44 
46  {
47  FASTUIDRAWassert(m_reference_count == 0);
48  }
49 
50  /*!
51  * Increment reference counter by 1.
52  */
53  void
55  {
56  ++m_reference_count;
57  }
58 
59  /*!
60  * Decrements the counter by 1 and returns status of if the counter
61  * is 0 after the decrement operation.
62  */
63  bool
65  {
66  --m_reference_count;
67  return m_reference_count == 0;
68  }
69 
70  private:
71  int m_reference_count;
72  };
73 /*! @} */
74 }
75 
76 #endif
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
file util.hpp
Reference counter that is NOT thread safe.
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505
#define FASTUIDRAWassert(X)
Definition: util.hpp:99