intrusive_refcount.cci
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 
14 /** \file
15  \brief intrusive_refcount inline non-template implementation */
16 
17 //#include "intrusive_refcount.ih"
18 
19 // Custom includes
20 #include "senfassert.hh"
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 prefix_ senf::intrusive_refcount_base::~intrusive_refcount_base()
26 {}
27 
28 prefix_ senf::intrusive_refcount_base::refcount_t senf::intrusive_refcount_base::refcount()
29  const
30 {
31  return refcount_;
32 }
33 
34 prefix_ bool senf::intrusive_refcount_base::is_shared()
35  const
36 {
37  return refcount()>1;
38 }
39 
40 prefix_ senf::intrusive_refcount_base::intrusive_refcount_base()
41  : refcount_(0)
42 {}
43 
44 prefix_ void senf::intrusive_refcount_base::add_ref()
45 {
46  ++refcount_;
47 }
48 
49 prefix_ bool senf::intrusive_refcount_base::release()
50 {
51  SENF_ASSERT(refcount_>0,
52  "senf::intrusive_refcount_base: Internal inconsistency: "
53  "Calling release on dead object.");
54  return --refcount_ == 0;
55 }
56 
57 prefix_ senf::intrusive_refcount::intrusive_refcount()
58 {}
59 
60 //-/////////////////////////////////////////////////////////////////////////////////////////////////
61 #undef prefix_
62 
63 
64 // Local Variables:
65 // mode: c++
66 // fill-column: 100
67 // c-file-style: "senf"
68 // indent-tabs-mode: nil
69 // ispell-local-dictionary: "american"
70 // compile-command: "scons -u test"
71 // comment-column: 40
72 // End: