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.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/boost/fiber/detail/spinlock.hpp b/boost/fiber/detail/spinlock.hpp
new file mode 100644
index 0000000000..e2af3a86c7
--- /dev/null
+++ b/boost/fiber/detail/spinlock.hpp
@@ -0,0 +1,42 @@
+
+// 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)
+//
+// based on boost::interprocess::sync::interprocess_spin::mutex
+
+#ifndef BOOST_FIBERS_SPINLOCK_H
+#define BOOST_FIBERS_SPINLOCK_H
+
+#include <mutex>
+
+#include <boost/fiber/detail/config.hpp>
+
+namespace boost {
+namespace fibers {
+namespace detail {
+
+struct non_spinlock {
+ constexpr non_spinlock() noexcept {}
+ void lock() noexcept {}
+ void unlock() noexcept {}
+};
+
+struct non_lock {
+ constexpr non_lock( non_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;
+#endif
+
+}}}
+
+#endif // BOOST_FIBERS_SPINLOCK_H