]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/smart_ptr/detail/spinlock_nt.hpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / boost / smart_ptr / detail / spinlock_nt.hpp
CommitLineData
7c673cae
FG
1#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
2#define BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_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/assert.hpp>
19
20effc67
TL
20#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
21
22#include <boost/config/pragma_message.hpp>
23BOOST_PRAGMA_MESSAGE("Using single-threaded spinlock emulation")
24
25#endif
26
7c673cae
FG
27namespace boost
28{
29
30namespace detail
31{
32
33class spinlock
34{
35public:
36
37 bool locked_;
38
39public:
40
41 inline bool try_lock()
42 {
43 if( locked_ )
44 {
45 return false;
46 }
47 else
48 {
49 locked_ = true;
50 return true;
51 }
52 }
53
54 inline void lock()
55 {
56 BOOST_ASSERT( !locked_ );
57 locked_ = true;
58 }
59
60 inline void unlock()
61 {
62 BOOST_ASSERT( locked_ );
63 locked_ = false;
64 }
65
66public:
67
68 class scoped_lock
69 {
70 private:
71
72 spinlock & sp_;
73
74 scoped_lock( scoped_lock const & );
75 scoped_lock & operator=( scoped_lock const & );
76
77 public:
78
79 explicit scoped_lock( spinlock & sp ): sp_( sp )
80 {
81 sp.lock();
82 }
83
84 ~scoped_lock()
85 {
86 sp_.unlock();
87 }
88 };
89};
90
91} // namespace detail
92} // namespace boost
93
94#define BOOST_DETAIL_SPINLOCK_INIT { false }
95
96#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED