This is Unofficial EPICS BASE Doxygen Site
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
spinlock_pt.hpp
Go to the documentation of this file.
1
#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
2
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_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 <pthread.h>
19
20
namespace
boost
21
{
22
23
namespace
detail
24
{
25
26
class
spinlock
27
{
28
public
:
29
30
pthread_mutex_t
v_
;
31
32
public
:
33
34
bool
try_lock
()
35
{
36
return
pthread_mutex_trylock( &v_ ) == 0;
37
}
38
39
void
lock
()
40
{
41
pthread_mutex_lock( &v_ );
42
}
43
44
void
unlock
()
45
{
46
pthread_mutex_unlock( &v_ );
47
}
48
49
public
:
50
51
class
scoped_lock
52
{
53
private
:
54
55
spinlock
& sp_;
56
57
scoped_lock
(
scoped_lock
const
& );
58
scoped_lock
& operator=(
scoped_lock
const
& );
59
60
public
:
61
62
explicit
scoped_lock
(
spinlock
& sp ): sp_( sp )
63
{
64
sp.
lock
();
65
}
66
67
~scoped_lock
()
68
{
69
sp_.
unlock
();
70
}
71
};
72
};
73
74
}
// namespace detail
75
}
// namespace boost
76
77
#define BOOST_DETAIL_SPINLOCK_INIT { PTHREAD_MUTEX_INITIALIZER }
78
79
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
boost
Definition:
assert.hpp:91
boost::detail::spinlock::lock
void lock()
Definition:
spinlock_pt.hpp:39
boost::detail::spinlock::try_lock
bool try_lock()
Definition:
spinlock_pt.hpp:34
boost::detail::spinlock::scoped_lock::scoped_lock
scoped_lock(spinlock &sp)
Definition:
spinlock_pt.hpp:62
detail
Definition:
pvUnitTest.h:17
boost::detail::spinlock
Definition:
spinlock_pt.hpp:26
boost::detail::spinlock::scoped_lock
Definition:
spinlock_pt.hpp:51
boost::detail::spinlock::unlock
void unlock()
Definition:
spinlock_pt.hpp:44
boost::detail::spinlock::scoped_lock::~scoped_lock
~scoped_lock()
Definition:
spinlock_pt.hpp:67
boost::detail::spinlock::v_
pthread_mutex_t v_
Definition:
spinlock_pt.hpp:30
modules
libcom
vxWorks
boost
smart_ptr
detail
spinlock_pt.hpp
Generated by
1.8.11