spinlock_nt.hpp
Go to the documentation of this file.
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 
20 namespace boost
21 {
22 
23 namespace detail
24 {
25 
26 class spinlock
27 {
28 public:
29 
30  bool locked_;
31 
32 public:
33 
34  inline bool try_lock()
35  {
36  if( locked_ )
37  {
38  return false;
39  }
40  else
41  {
42  locked_ = true;
43  return true;
44  }
45  }
46 
47  inline void lock()
48  {
50  locked_ = true;
51  }
52 
53  inline void unlock()
54  {
56  locked_ = false;
57  }
58 
59 public:
60 
61  class scoped_lock
62  {
63  private:
64 
65  spinlock & sp_;
66 
67  scoped_lock( scoped_lock const & );
68  scoped_lock & operator=( scoped_lock const & );
69 
70  public:
71 
72  explicit scoped_lock( spinlock & sp ): sp_( sp )
73  {
74  sp.lock();
75  }
76 
78  {
79  sp_.unlock();
80  }
81  };
82 };
83 
84 } // namespace detail
85 } // namespace boost
86 
87 #define BOOST_DETAIL_SPINLOCK_INIT { false }
88 
89 #endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
boost::detail::spinlock::lock
void lock()
Definition: spinlock_nt.hpp:47
boost::detail::spinlock
Definition: spinlock_gcc_arm.hpp:36
boost::detail::spinlock::try_lock
bool try_lock()
Definition: spinlock_nt.hpp:34
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::detail::spinlock::scoped_lock::scoped_lock
scoped_lock(spinlock &sp)
Definition: spinlock_nt.hpp:72
boost::detail::spinlock::locked_
bool locked_
Definition: spinlock_nt.hpp:30
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_ASSERT
#define BOOST_ASSERT(expr)
Definition: assert.hpp:60
boost::detail::spinlock::scoped_lock::scoped_lock
scoped_lock(scoped_lock const &)
assert.hpp
boost::detail::spinlock::scoped_lock::~scoped_lock
~scoped_lock()
Definition: spinlock_nt.hpp:77
boost::detail::spinlock::unlock
void unlock()
Definition: spinlock_nt.hpp:53


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:48:40