summaryrefslogtreecommitdiff
path: root/boost/fiber/detail/spinlock.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/fiber/detail/spinlock.hpp')
-rw-r--r--boost/fiber/detail/spinlock.hpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/boost/fiber/detail/spinlock.hpp b/boost/fiber/detail/spinlock.hpp
index e2af3a86c7..89a6d51a6f 100644
--- a/boost/fiber/detail/spinlock.hpp
+++ b/boost/fiber/detail/spinlock.hpp
@@ -3,40 +3,63 @@
// 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)
-//
-// based on boost::interprocess::sync::interprocess_spin::mutex
#ifndef BOOST_FIBERS_SPINLOCK_H
#define BOOST_FIBERS_SPINLOCK_H
-#include <mutex>
+#include <boost/config.hpp>
#include <boost/fiber/detail/config.hpp>
+#if !defined(BOOST_FIBERS_NO_ATOMICS)
+# include <mutex>
+# include <boost/fiber/detail/spinlock_ttas.hpp>
+# include <boost/fiber/detail/spinlock_ttas_adaptive.hpp>
+# if defined(BOOST_FIBERS_HAS_FUTEX)
+# include <boost/fiber/detail/spinlock_ttas_futex.hpp>
+# include <boost/fiber/detail/spinlock_ttas_adaptive_futex.hpp>
+# endif
+#endif
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
namespace boost {
namespace fibers {
namespace detail {
-struct non_spinlock {
- constexpr non_spinlock() noexcept {}
+#if defined(BOOST_FIBERS_NO_ATOMICS)
+struct spinlock {
+ constexpr spinlock() noexcept {}
void lock() noexcept {}
void unlock() noexcept {}
};
-struct non_lock {
- constexpr non_lock( non_spinlock) noexcept {}
+struct spinlock_lock {
+ constexpr spinlock_lock( spinlock &) noexcept {}
void lock() noexcept {}
void unlock() noexcept {}
};
-
-#if ! defined(BOOST_FIBERS_NO_ATOMICS)
-typedef std::mutex spinlock;
-using spinlock_lock = std::unique_lock< spinlock >;
#else
-typedef non_spinlock spinlock;
-using spinlock_lock = non_lock;
+# if defined(BOOST_FIBERS_SPINLOCK_STD_MUTEX)
+using spinlock = std::mutex;
+# elif defined(BOOST_FIBERS_SPINLOCK_TTAS_FUTEX)
+using spinlock = spinlock_ttas_futex;
+# elif defined(BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE_FUTEX)
+using spinlock = spinlock_ttas_adaptive_futex;
+# elif defined(BOOST_FIBERS_SPINLOCK_TTAS_ADAPTIVE)
+using spinlock = spinlock_ttas_adaptive;
+# else
+using spinlock = spinlock_ttas;
+# endif
+using spinlock_lock = std::unique_lock< spinlock >;
#endif
}}}
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
#endif // BOOST_FIBERS_SPINLOCK_H