Main Page
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Variables
_
a
b
i
k
n
p
r
s
t
v
Typedefs
a
b
c
f
h
i
m
n
p
s
t
u
w
y
Enumerations
Enumerator
a
b
c
e
f
h
i
l
m
n
o
p
r
s
t
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
~
Variables
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
Enumerator
a
b
c
e
g
i
k
l
m
n
o
p
r
s
u
v
Related Functions
a
b
c
d
e
i
l
m
o
r
s
u
w
x
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
g
m
o
p
r
s
t
Variables
_
a
b
f
g
l
t
u
Typedefs
Enumerations
Enumerator
Macros
_
a
b
c
e
f
g
i
l
m
r
s
u
v
w
x
sick_visionary_cpp_shared
3pp
boost
smart_ptr
detail
sp_counted_base_aix.hpp
Go to the documentation of this file.
1
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED
2
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED
3
4
//
5
// detail/sp_counted_base_aix.hpp
6
// based on: detail/sp_counted_base_w32.hpp
7
//
8
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
9
// Copyright 2004-2005 Peter Dimov
10
// Copyright 2006 Michael van der Westhuizen
11
//
12
// Distributed under the Boost Software License, Version 1.0. (See
13
// accompanying file LICENSE_1_0.txt or copy at
14
// http://www.boost.org/LICENSE_1_0.txt)
15
//
16
//
17
// Lock-free algorithm by Alexander Terekhov
18
//
19
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
20
// formulation
21
//
22
23
#include <
boost/detail/sp_typeinfo.hpp
>
24
#include <builtins.h>
25
#include <sys/atomic_op.h>
26
27
namespace
boost
28
{
29
30
namespace
detail
31
{
32
33
inline
void
atomic_increment
( int32_t* pw )
34
{
35
// ++*pw;
36
37
fetch_and_add( pw, 1 );
38
}
39
40
inline
int32_t
atomic_decrement
( int32_t * pw )
41
{
42
// return --*pw;
43
44
int32_t originalValue;
45
46
__lwsync
();
47
originalValue = fetch_and_add( pw, -1 );
48
__isync
();
49
50
return
(originalValue - 1);
51
}
52
53
inline
int32_t
atomic_conditional_increment
( int32_t * pw )
54
{
55
// if( *pw != 0 ) ++*pw;
56
// return *pw;
57
58
int32_t tmp = fetch_and_add( pw, 0 );
59
for
( ;; )
60
{
61
if
( tmp == 0 )
return
0;
62
if
(
compare_and_swap
( pw, &tmp, tmp + 1 ) )
return
(tmp + 1);
63
}
64
}
65
66
class
sp_counted_base
67
{
68
private
:
69
70
sp_counted_base
(
sp_counted_base
const
& );
71
sp_counted_base
&
operator=
(
sp_counted_base
const
& );
72
73
int32_t
use_count_
;
// #shared
74
int32_t
weak_count_
;
// #weak + (#shared != 0)
75
76
public
:
77
78
sp_counted_base
():
use_count_
( 1 ),
weak_count_
( 1 )
79
{
80
}
81
82
virtual
~sp_counted_base
()
// nothrow
83
{
84
}
85
86
// dispose() is called when use_count_ drops to zero, to release
87
// the resources managed by *this.
88
89
virtual
void
dispose
() = 0;
// nothrow
90
91
// destroy() is called when weak_count_ drops to zero.
92
93
virtual
void
destroy
()
// nothrow
94
{
95
delete
this
;
96
}
97
98
virtual
void
*
get_deleter
(
sp_typeinfo
const
& ti ) = 0;
99
virtual
void
*
get_untyped_deleter
() = 0;
100
101
void
add_ref_copy
()
102
{
103
atomic_increment
( &
use_count_
);
104
}
105
106
bool
add_ref_lock
()
// true on success
107
{
108
return
atomic_conditional_increment
( &
use_count_
) != 0;
109
}
110
111
void
release
()
// nothrow
112
{
113
if
(
atomic_decrement
( &
use_count_
) == 0 )
114
{
115
dispose
();
116
weak_release
();
117
}
118
}
119
120
void
weak_add_ref
()
// nothrow
121
{
122
atomic_increment
( &
weak_count_
);
123
}
124
125
void
weak_release
()
// nothrow
126
{
127
if
(
atomic_decrement
( &
weak_count_
) == 0 )
128
{
129
destroy
();
130
}
131
}
132
133
long
use_count
() const
// nothrow
134
{
135
return
fetch_and_add(
const_cast<
int32_t*
>
(&
use_count_
), 0 );
136
}
137
};
138
139
}
// namespace detail
140
141
}
// namespace boost
142
143
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_AIX_HPP_INCLUDED
boost::detail::atomic_increment
void atomic_increment(int *pw)
Definition:
sp_counted_base_acc_ia64.hpp:27
boost::detail::sp_counted_base::get_untyped_deleter
virtual void * get_untyped_deleter()=0
boost::detail::sp_counted_base::weak_count_
int32_t weak_count_
Definition:
sp_counted_base_aix.hpp:74
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::detail::sp_counted_base::destroy
virtual void destroy()
Definition:
sp_counted_base_aix.hpp:93
boost::detail::sp_counted_base::add_ref_copy
void add_ref_copy()
Definition:
sp_counted_base_aix.hpp:101
sp_typeinfo.hpp
boost::detail::sp_counted_base::weak_release
void weak_release()
Definition:
sp_counted_base_acc_ia64.hpp:133
boost::detail::sp_counted_base::add_ref_lock
bool add_ref_lock()
Definition:
sp_counted_base_aix.hpp:106
boost::detail::compare_and_swap
int32_t compare_and_swap(int32_t *dest_, int32_t compare_, int32_t swap_)
Definition:
sp_counted_base_gcc_sparc.hpp:31
__isync
builtin void __isync(void)
boost::detail::sp_typeinfo
boost::core::typeinfo sp_typeinfo
Definition:
sp_typeinfo.hpp:28
boost::detail::sp_counted_base::get_deleter
virtual void * get_deleter(sp_typeinfo const &ti)=0
boost::detail::sp_counted_base::use_count
long use_count() const
Definition:
sp_counted_base_aix.hpp:133
boost::detail::sp_counted_base::use_count_
int32_t use_count_
Definition:
sp_counted_base_aix.hpp:73
boost::detail::sp_counted_base::dispose
virtual void dispose()=0
boost::detail::sp_counted_base::~sp_counted_base
virtual ~sp_counted_base()
Definition:
sp_counted_base_aix.hpp:82
boost::detail::sp_counted_base::operator=
sp_counted_base & operator=(sp_counted_base const &)
boost::detail::atomic_conditional_increment
int atomic_conditional_increment(int *pw)
Definition:
sp_counted_base_acc_ia64.hpp:47
boost::detail::sp_counted_base::sp_counted_base
sp_counted_base()
Definition:
sp_counted_base_acc_ia64.hpp:86
boost::detail::sp_counted_base::release
void release()
Definition:
sp_counted_base_aix.hpp:111
boost::detail::atomic_decrement
int atomic_decrement(int *pw)
Definition:
sp_counted_base_acc_ia64.hpp:34
boost::detail::sp_counted_base::use_count_
int use_count_
Definition:
sp_counted_base_acc_ia64.hpp:81
boost::detail::sp_counted_base::weak_count_
int weak_count_
Definition:
sp_counted_base_acc_ia64.hpp:82
__lwsync
builtin void __lwsync(void)
boost::detail::sp_counted_base::weak_add_ref
void weak_add_ref()
Definition:
sp_counted_base_aix.hpp:120
sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:48:40