Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
ref_counted_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Roc Streaming authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_core/ref_counted_impl.h
10 //! @brief Implementation class for reference counter.
11 
12 #ifndef ROC_CORE_REF_COUNTED_IMPL_H_
13 #define ROC_CORE_REF_COUNTED_IMPL_H_
14 
15 #include "roc_core/atomic.h"
16 
17 namespace roc {
18 namespace core {
19 
20 //! Implementation class for reference counter.
21 //!
22 //! Allows to increment and decrement reference counter.
24 public:
25  //! Initialize.
27 
28  ~RefCountedImpl();
29 
30  //! Get reference counter.
31  int getref() const;
32 
33  //! Increment reference counter.
34  //! @returns reference counter value after incrementing.
35  int incref() const;
36 
37  //! Decrement reference counter.
38  //! @returns reference counter value after decrementing.
39  int decref() const;
40 
41 private:
42  enum { MaxCounter = 100000 };
43 
44  mutable Atomic<int> counter_;
45 };
46 
47 } // namespace core
48 } // namespace roc
49 
50 #endif // ROC_CORE_REF_COUNTED_IMPL_H_
Atomic.
Implementation class for reference counter.
int incref() const
Increment reference counter.
int decref() const
Decrement reference counter.
int getref() const
Get reference counter.
Root namespace.