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
spinlock_w32.hpp
Go to the documentation of this file.
1
#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED
2
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_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
// Copyright (c) 2008 Peter Dimov
12
//
13
// Distributed under the Boost Software License, Version 1.0.
14
// See accompanying file LICENSE_1_0.txt or copy at
15
// http://www.boost.org/LICENSE_1_0.txt)
16
//
17
18
#include <
boost/smart_ptr/detail/sp_interlocked.hpp
>
19
#include <
boost/smart_ptr/detail/yield_k.hpp
>
20
21
// BOOST_COMPILER_FENCE
22
23
#if defined(__INTEL_COMPILER)
24
25
#define BOOST_COMPILER_FENCE __memory_barrier();
26
27
#elif defined( _MSC_VER ) && _MSC_VER >= 1310
28
29
extern
"C"
void
_ReadWriteBarrier();
30
#pragma intrinsic( _ReadWriteBarrier )
31
32
#define BOOST_COMPILER_FENCE _ReadWriteBarrier();
33
34
#elif defined(__GNUC__)
35
36
#define BOOST_COMPILER_FENCE __asm__ __volatile__( "" : : : "memory" );
37
38
#else
39
40
#define BOOST_COMPILER_FENCE
41
42
#endif
43
44
//
45
46
namespace
boost
47
{
48
49
namespace
detail
50
{
51
52
class
spinlock
53
{
54
public
:
55
56
long
v_
;
57
58
public
:
59
60
bool
try_lock
()
61
{
62
long
r = BOOST_SP_INTERLOCKED_EXCHANGE( &
v_
, 1 );
63
64
BOOST_COMPILER_FENCE
65
66
return
r == 0;
67
}
68
69
void
lock
()
70
{
71
for
(
unsigned
k = 0; !
try_lock
(); ++k )
72
{
73
boost::detail::yield
( k );
74
}
75
}
76
77
void
unlock
()
78
{
79
BOOST_COMPILER_FENCE
80
*
const_cast<
long
volatile*
>
( &
v_
) = 0;
81
}
82
83
public
:
84
85
class
scoped_lock
86
{
87
private
:
88
89
spinlock
&
sp_
;
90
91
scoped_lock
(
scoped_lock
const
& );
92
scoped_lock
&
operator=
(
scoped_lock
const
& );
93
94
public
:
95
96
explicit
scoped_lock
(
spinlock
& sp ):
sp_
( sp )
97
{
98
sp.lock();
99
}
100
101
~scoped_lock
()
102
{
103
sp_
.
unlock
();
104
}
105
};
106
};
107
108
}
// namespace detail
109
}
// namespace boost
110
111
#define BOOST_DETAIL_SPINLOCK_INIT {0}
112
113
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_W32_HPP_INCLUDED
BOOST_COMPILER_FENCE
#define BOOST_COMPILER_FENCE
Definition:
spinlock_w32.hpp:40
boost::detail::spinlock::lock
void lock()
Definition:
spinlock_w32.hpp:69
boost::detail::spinlock::v_
int v_
Definition:
spinlock_gcc_arm.hpp:40
boost::detail::spinlock
Definition:
spinlock_gcc_arm.hpp:36
boost::detail::spinlock::try_lock
bool try_lock()
Definition:
spinlock_w32.hpp:60
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::detail::spinlock::scoped_lock::scoped_lock
scoped_lock(spinlock &sp)
Definition:
spinlock_w32.hpp:96
boost::detail::spinlock::scoped_lock::operator=
scoped_lock & operator=(scoped_lock const &)
boost::detail::spinlock::scoped_lock::sp_
spinlock & sp_
Definition:
spinlock_gcc_arm.hpp:94
boost::detail::yield
void yield(unsigned)
Definition:
yield_k.hpp:167
boost::detail::spinlock::v_
long v_
Definition:
spinlock_w32.hpp:56
boost::detail::spinlock::scoped_lock::scoped_lock
scoped_lock(scoped_lock const &)
boost::detail::spinlock::scoped_lock::~scoped_lock
~scoped_lock()
Definition:
spinlock_w32.hpp:101
yield_k.hpp
sp_interlocked.hpp
boost::detail::spinlock::unlock
void unlock()
Definition:
spinlock_w32.hpp:77
sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:48:40