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_cw_ppc.hpp
Go to the documentation of this file.
1
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
2
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_HPP_INCLUDED
3
4
// MS compatible compilers support #pragma once
5
6
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7
# pragma once
8
#endif
9
10
//
11
// detail/sp_counted_base_cw_ppc.hpp - CodeWarrior on PowerPC
12
//
13
// Copyright (c) 2001, 2002, 2003 Peter Dimov and Multi Media Ltd.
14
// Copyright 2004-2005 Peter Dimov
15
//
16
// Distributed under the Boost Software License, Version 1.0. (See
17
// accompanying file LICENSE_1_0.txt or copy at
18
// http://www.boost.org/LICENSE_1_0.txt)
19
//
20
//
21
// Lock-free algorithm by Alexander Terekhov
22
//
23
// Thanks to Ben Hitchings for the #weak + (#shared != 0)
24
// formulation
25
//
26
27
#include <
boost/detail/sp_typeinfo.hpp
>
28
29
namespace
boost
30
{
31
32
namespace
detail
33
{
34
35
inline
void
atomic_increment
(
register
long
* pw )
36
{
37
register
int
a;
38
39
asm
40
{
41
loop:
42
43
lwarx a, 0, pw
44
addi a, a, 1
45
stwcx. a, 0, pw
46
bne- loop
47
}
48
}
49
50
inline
long
atomic_decrement
(
register
long
* pw )
51
{
52
register
int
a;
53
54
asm
55
{
56
sync
57
58
loop:
59
60
lwarx a, 0, pw
61
addi a, a, -1
62
stwcx. a, 0, pw
63
bne- loop
64
65
isync
66
}
67
68
return
a;
69
}
70
71
inline
long
atomic_conditional_increment
(
register
long
* pw )
72
{
73
register
int
a;
74
75
asm
76
{
77
loop:
78
79
lwarx a, 0, pw
80
cmpwi a, 0
81
beq store
82
83
addi a, a, 1
84
85
store:
86
87
stwcx. a, 0, pw
88
bne- loop
89
}
90
91
return
a;
92
}
93
94
class
sp_counted_base
95
{
96
private
:
97
98
sp_counted_base
(
sp_counted_base
const
& );
99
sp_counted_base
&
operator=
(
sp_counted_base
const
& );
100
101
long
use_count_
;
// #shared
102
long
weak_count_
;
// #weak + (#shared != 0)
103
104
public
:
105
106
sp_counted_base
():
use_count_
( 1 ),
weak_count_
( 1 )
107
{
108
}
109
110
virtual
~sp_counted_base
()
// nothrow
111
{
112
}
113
114
// dispose() is called when use_count_ drops to zero, to release
115
// the resources managed by *this.
116
117
virtual
void
dispose
() = 0;
// nothrow
118
119
// destroy() is called when weak_count_ drops to zero.
120
121
virtual
void
destroy
()
// nothrow
122
{
123
delete
this
;
124
}
125
126
virtual
void
*
get_deleter
(
sp_typeinfo
const
& ti ) = 0;
127
virtual
void
*
get_untyped_deleter
() = 0;
128
129
void
add_ref_copy
()
130
{
131
atomic_increment
( &
use_count_
);
132
}
133
134
bool
add_ref_lock
()
// true on success
135
{
136
return
atomic_conditional_increment
( &
use_count_
) != 0;
137
}
138
139
void
release
()
// nothrow
140
{
141
if
(
atomic_decrement
( &
use_count_
) == 0 )
142
{
143
dispose
();
144
weak_release
();
145
}
146
}
147
148
void
weak_add_ref
()
// nothrow
149
{
150
atomic_increment
( &
weak_count_
);
151
}
152
153
void
weak_release
()
// nothrow
154
{
155
if
(
atomic_decrement
( &
weak_count_
) == 0 )
156
{
157
destroy
();
158
}
159
}
160
161
long
use_count
() const
// nothrow
162
{
163
return
static_cast<
long
const
volatile
&
>
(
use_count_
);
164
}
165
};
166
167
}
// namespace detail
168
169
}
// namespace boost
170
171
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_CW_PPC_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
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::detail::sp_counted_base::destroy
virtual void destroy()
Definition:
sp_counted_base_cw_ppc.hpp:121
boost::detail::sp_counted_base::add_ref_copy
void add_ref_copy()
Definition:
sp_counted_base_cw_ppc.hpp:129
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_cw_ppc.hpp:134
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_cw_ppc.hpp:161
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_cw_ppc.hpp:110
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_cw_ppc.hpp:139
boost::detail::atomic_decrement
int atomic_decrement(int *pw)
Definition:
sp_counted_base_acc_ia64.hpp:34
boost::detail::sp_counted_base::use_count_
long use_count_
Definition:
sp_counted_base_cw_ppc.hpp:101
boost::detail::sp_counted_base::weak_count_
long weak_count_
Definition:
sp_counted_base_cw_ppc.hpp:102
boost::detail::sp_counted_base::weak_add_ref
void weak_add_ref()
Definition:
sp_counted_base_cw_ppc.hpp:148
sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:48:40