intrusive_refcount.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_intrusive_refcount_
18 #define HH_SENF_Utils_intrusive_refcount_ 1
19 
20 // Custom includes
21 #include <boost/noncopyable.hpp>
22 
23 //#include "intrusive_refcount.mpp"
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 namespace senf {
27 
28  template <class Self> class intrusive_refcount_t;
29 
30  template <class Self>
32  template <class Self>
34 
35 
42  : public boost::noncopyable
43  {
44  public:
45  typedef unsigned refcount_t;
46 
47  virtual ~intrusive_refcount_base();
48 
49  refcount_t refcount() const;
50  bool is_shared() const;
51 
52  protected:
54 
55  void add_ref();
56  bool release();
57 
58  private:
59  refcount_t refcount_;
60 
61  template <class S> void intrusive_ptr_add_ref();
62  template <class S> void intrusive_ptr_release();
63 
64  template <class S>
66  template <class S>
68  };
69 
116  template <class Self>
118  : public intrusive_refcount_base
119  {
120  protected:
122  };
123 
151  : public intrusive_refcount_t<intrusive_refcount>
152  {
153  protected:
155  };
156 
157 }
158 
159 //-/////////////////////////////////////////////////////////////////////////////////////////////////
160 #include "intrusive_refcount.cci"
161 //#include "intrusive_refcount.ct"
162 #include "intrusive_refcount.cti"
163 #endif
164 
165 
166 // Local Variables:
167 // mode: c++
168 // fill-column: 100
169 // c-file-style: "senf"
170 // indent-tabs-mode: nil
171 // ispell-local-dictionary: "american"
172 // compile-command: "scons -u test"
173 // comment-column: 40
174 // End:
void intrusive_ptr_release(intrusive_refcount_t< Self > const *p)
Reference count mixin for intrusive_ptr.
bool is_shared() const
return true if refcount() > 1
Customizable reference count mixin for intrusive_ptr.
unsigned refcount_t
reference count type
Reference count mixin interface baseclass.
void intrusive_ptr_add_ref(intrusive_refcount_t< Self > const *p)
refcount_t refcount() const
current refcount