Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
p
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
m
n
p
r
s
t
u
w
Variables
a
b
c
d
e
f
g
h
i
l
m
p
r
s
t
u
w
Typedefs
a
c
d
g
i
l
m
p
r
s
t
u
v
Enumerations
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Related Functions
Files
File List
File Members
All
_
c
e
g
i
j
m
n
o
p
s
t
u
w
y
Functions
c
e
g
m
o
p
s
t
u
w
y
Variables
Typedefs
Macros
_
c
e
i
m
n
p
s
w
sensor_api
source
Wire
include
utility
ReferenceCount.hh
Go to the documentation of this file.
1
41
#ifndef CRL_MULTISENSE_REFERENCECOUNT_HH
42
#define CRL_MULTISENSE_REFERENCECOUNT_HH
43
44
#include <stdint.h>
45
46
namespace
crl
{
47
namespace
multisense
{
48
namespace
details {
49
namespace
utility {
50
51
class
ReferenceCount
52
{
53
public
:
54
55
bool
isShared
()
const
{
56
if
(
m_countP
&& (*
m_countP
) > 1)
57
return
true
;
58
return
false
;
59
}
60
61
void
reset
() {
62
release
();
63
m_countP
=
new
int32_t(1);
64
}
65
66
ReferenceCount
()
67
:
m_countP
(new int32_t(1)) {};
68
69
ReferenceCount
(
const
ReferenceCount
& source)
70
:
m_countP
(source.
m_countP
) {
71
share
();
72
}
73
74
~ReferenceCount
() {
75
release
();
76
}
77
78
ReferenceCount
&
operator=
(
const
ReferenceCount
& source) {
79
if
(
this
!= &source) {
80
release
();
81
m_countP
= source.
m_countP
;
82
share
();
83
}
84
return
*
this
;
85
}
86
87
private
:
88
89
volatile
int32_t *
m_countP
;
90
91
void
share
() {
92
if
(
m_countP
)
93
#ifdef WIN32
94
InterlockedIncrement((LONG*)
m_countP
);
95
#else
96
__sync_fetch_and_add(
m_countP
, 1);
97
#endif
98
}
99
100
void
release
() {
101
if
(
m_countP
) {
102
#ifdef WIN32
103
int32_t count = InterlockedDecrement((LONG*)
m_countP
);
104
#else
105
int32_t count = __sync_sub_and_fetch(
m_countP
, 1);
106
#endif
107
if
(count <= 0)
108
delete
m_countP
;
109
m_countP
= NULL;
110
}
111
}
112
};
113
114
}}}}
// namespaces
115
116
#endif
/* #ifndef CRL_MULTISENSE_REFERENCECOUNT_HH */
crl::multisense::details::utility::ReferenceCount::m_countP
volatile int32_t * m_countP
Definition:
ReferenceCount.hh:89
crl::multisense::details::utility::ReferenceCount
Definition:
ReferenceCount.hh:51
crl::multisense::details::utility::ReferenceCount::share
void share()
Definition:
ReferenceCount.hh:91
crl::multisense::details::utility::ReferenceCount::~ReferenceCount
~ReferenceCount()
Definition:
ReferenceCount.hh:74
crl::multisense::details::utility::ReferenceCount::ReferenceCount
ReferenceCount(const ReferenceCount &source)
Definition:
ReferenceCount.hh:69
crl::multisense::details::utility::ReferenceCount::isShared
bool isShared() const
Definition:
ReferenceCount.hh:55
crl
Definition:
Legacy/details/channel.cc:61
crl::multisense::details::utility::ReferenceCount::reset
void reset()
Definition:
ReferenceCount.hh:61
crl::multisense::details::utility::ReferenceCount::release
void release()
Definition:
ReferenceCount.hh:100
crl::multisense::details::utility::ReferenceCount::ReferenceCount
ReferenceCount()
Definition:
ReferenceCount.hh:66
multisense
Definition:
factory.cc:39
crl::multisense::details::utility::ReferenceCount::operator=
ReferenceCount & operator=(const ReferenceCount &source)
Definition:
ReferenceCount.hh:78
multisense_lib
Author(s):
autogenerated on Thu Apr 17 2025 02:49:09