Blame view

3rdparty/boost_1_81_0/boost/fiber/detail/spinlock.hpp 2.12 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  
  //          Copyright Oliver Kowalke 2013.
  // Distributed under the Boost Software License, Version 1.0.
  //    (See accompanying file LICENSE_1_0.txt or copy at
  //          http://www.boost.org/LICENSE_1_0.txt)
  
  #ifndef BOOST_FIBERS_SPINLOCK_H
  #define BOOST_FIBERS_SPINLOCK_H
  
  #include <boost/config.hpp>
  
  #include <boost/fiber/detail/config.hpp>
  
  #if !defined(BOOST_FIBERS_NO_ATOMICS) 
  # include <mutex>
  # include <boost/fiber/detail/spinlock_ttas_adaptive.hpp>
  # include <boost/fiber/detail/spinlock_ttas.hpp>
  # if defined(BOOST_FIBERS_HAS_FUTEX)
  #  include <boost/fiber/detail/spinlock_ttas_adaptive_futex.hpp>
  #  include <boost/fiber/detail/spinlock_ttas_futex.hpp>
  # endif
  # if defined(BOOST_USE_TSX)
  #  include <boost/fiber/detail/spinlock_rtm.hpp>
  # endif
  #endif
  
  #ifdef BOOST_HAS_ABI_HEADERS
  #  include BOOST_ABI_PREFIX
  #endif
  
  namespace boost {
  namespace fibers {
  namespace detail {
  
  #if defined(BOOST_FIBERS_NO_ATOMICS)
  struct spinlock {
      constexpr spinlock() noexcept {}
      void lock() noexcept {}
      void unlock() noexcept {}
  };
  
  struct spinlock_lock {
      constexpr spinlock_lock( spinlock &) noexcept {}
      void lock() noexcept {}
      void unlock() noexcept {}
  };
  #else
  # if defined(BOOST_FIBERS_SPINLOCK_STD_MUTEX)
  using spinlock = std::mutex;
  # elif defined(BOOST_FIBERS_SPINLOCK_TTAS_FUTEX)
  #  if defined(BOOST_USE_TSX)
  using spinlock = spinlock_rtm< spinlock_ttas_futex >;
  #  else
  using spinlock = spinlock_ttas_futex;
  #  endif
  # elif defined(BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE_FUTEX)
  #  if defined(BOOST_USE_TSX)
  using spinlock = spinlock_rtm< spinlock_ttas_adaptive_futex >;
  #  else
  using spinlock = spinlock_ttas_adaptive_futex;
  #  endif
  # elif defined(BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE)
  #  if defined(BOOST_USE_TSX)
  using spinlock = spinlock_rtm< spinlock_ttas_adaptive >;
  #  else
  using spinlock = spinlock_ttas_adaptive;
  #  endif
  # else
  #  if defined(BOOST_USE_TSX)
  using spinlock = spinlock_rtm< spinlock_ttas >;
  #  else
  using spinlock = spinlock_ttas;
  #  endif
  # endif
  using spinlock_lock = std::unique_lock< spinlock >;
  #endif
  
  }}}
  
  #ifdef BOOST_HAS_ABI_HEADERS
  #  include BOOST_ABI_SUFFIX
  #endif
  
  #endif // BOOST_FIBERS_SPINLOCK_H