FastUIDraw
reference_count_atomic.hpp
Go to the documentation of this file.
1 /*!
2  * \file reference_count_atomic.hpp
3  * \brief file reference_count_atomic.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_ATOMIC_HPP
21 #define FASTUIDRAW_REFERENCE_COUNT_ATOMIC_HPP
22 
23 #include <fastuidraw/util/util.hpp>
24 
25 namespace fastuidraw
26 {
27 /*!\addtogroup Utility
28  * @{
29  */
30 
31  /*!
32  * \brief
33  * Reference counter that is thread safe by
34  * having increment and decrement operations
35  * by atomic operations, this is usually faster
36  * (and much faster) than reference_count_mutex.
37  */
39  {
40  public:
41  /*!
42  * Initializes the counter as zero.
43  */
45 
47 
48  /*!
49  * Increment reference counter by 1.
50  */
51  void
52  add_reference(void);
53 
54  /*!
55  * Decrements the counter by 1 and returns status of if the counter
56  * is 0 after the decrement operation.
57  */
58  bool
59  remove_reference(void);
60 
61  private:
62  void *m_d;
63  };
64 
65 /*! @} */
66 }
67 
68 #endif
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
Reference counter that is thread safe by having increment and decrement operations by atomic operatio...
file util.hpp
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505