summaryrefslogtreecommitdiff
path: root/libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2025-05-02 07:42:02 +0200
committerJörg Frings-Fürst <debian@jff.email>2025-05-02 07:42:02 +0200
commitfc486627a4ecbae797fa6856d8a9204ea85f4db8 (patch)
treeff3dae4c0e5d980d8e2da4fc6256ae839269bbcd /libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp
parent1c188393cd2e271ed2581471b601fb5960777fd8 (diff)
parentecba0bbd9947036dd82f16ab95252f8db445e149 (diff)
Merge tag 'debian/4.0.0-10' into developdevelop
Bugfix release
Diffstat (limited to 'libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp')
-rw-r--r--libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp b/libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp
new file mode 100644
index 0000000..5ccad17
--- /dev/null
+++ b/libcutl/cutl/details/boost/smart_ptr/detail/spinlock_nt.hpp
@@ -0,0 +1,89 @@
+#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
+#define BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED
+
+// MS compatible compilers support #pragma once
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+//
+// Copyright (c) 2008 Peter Dimov
+//
+// 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)
+//
+
+#include <cutl/details/boost/assert.hpp>
+
+namespace cutl_details_boost
+{
+
+namespace detail
+{
+
+class spinlock
+{
+public:
+
+ bool locked_;
+
+public:
+
+ inline bool try_lock()
+ {
+ if( locked_ )
+ {
+ return false;
+ }
+ else
+ {
+ locked_ = true;
+ return true;
+ }
+ }
+
+ inline void lock()
+ {
+ BOOST_ASSERT( !locked_ );
+ locked_ = true;
+ }
+
+ inline void unlock()
+ {
+ BOOST_ASSERT( locked_ );
+ locked_ = false;
+ }
+
+public:
+
+ class scoped_lock
+ {
+ private:
+
+ spinlock & sp_;
+
+ scoped_lock( scoped_lock const & );
+ scoped_lock & operator=( scoped_lock const & );
+
+ public:
+
+ explicit scoped_lock( spinlock & sp ): sp_( sp )
+ {
+ sp.lock();
+ }
+
+ ~scoped_lock()
+ {
+ sp_.unlock();
+ }
+ };
+};
+
+} // namespace detail
+} // namespace cutl_details_boost
+
+#define BOOST_DETAIL_SPINLOCK_INIT { false }
+
+#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_NT_HPP_INCLUDED