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.
23
class
RefCountedImpl
{
24
public
:
25
//! Initialize.
26
RefCountedImpl
();
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.h
Atomic.
roc::core::Atomic< int >
roc::core::RefCountedImpl
Implementation class for reference counter.
Definition:
ref_counted_impl.h:23
roc::core::RefCountedImpl::incref
int incref() const
Increment reference counter.
roc::core::RefCountedImpl::RefCountedImpl
RefCountedImpl()
Initialize.
roc::core::RefCountedImpl::decref
int decref() const
Decrement reference counter.
roc::core::RefCountedImpl::getref
int getref() const
Get reference counter.
roc
Root namespace.
roc_core
ref_counted_impl.h
Generated by
1.9.1