diff --git a/include/boost/smart_ptr/detail/lightweight_mutex.hpp b/include/boost/smart_ptr/detail/lightweight_mutex.hpp index d46b193..7b098c4 100644 --- a/include/boost/smart_ptr/detail/lightweight_mutex.hpp +++ b/include/boost/smart_ptr/detail/lightweight_mutex.hpp @@ -28,15 +28,12 @@ #include -#if !defined(BOOST_HAS_THREADS) -# include -#elif defined(BOOST_HAS_PTHREADS) -# include -#elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#if !defined(BOOST_NO_CXX11_HDR_MUTEX ) +# include +#elif defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # include #else -// Use #define BOOST_DISABLE_THREADS to avoid the error -# error Unrecognized threading platform +# include #endif #endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED diff --git a/include/boost/smart_ptr/detail/lwm_nop.hpp b/include/boost/smart_ptr/detail/lwm_nop.hpp deleted file mode 100644 index 521a88e..0000000 --- a/include/boost/smart_ptr/detail/lwm_nop.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED -#define BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED - -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -// -// boost/detail/lwm_nop.hpp -// -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// -// 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) -// - -namespace boost -{ - -namespace detail -{ - -class lightweight_mutex -{ -public: - - typedef lightweight_mutex scoped_lock; -}; - -} // namespace detail - -} // namespace boost - -#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_NOP_HPP_INCLUDED diff --git a/include/boost/smart_ptr/detail/lwm_std_mutex.hpp b/include/boost/smart_ptr/detail/lwm_std_mutex.hpp new file mode 100644 index 0000000..5cb7490 --- /dev/null +++ b/include/boost/smart_ptr/detail/lwm_std_mutex.hpp @@ -0,0 +1,62 @@ +#ifndef BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED +#define BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED + +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +namespace boost +{ + +namespace detail +{ + +class lightweight_mutex +{ +private: + + std::mutex m_; + + lightweight_mutex(lightweight_mutex const &); + lightweight_mutex & operator=(lightweight_mutex const &); + +public: + + lightweight_mutex() + { + } + + class scoped_lock; + friend class scoped_lock; + + class scoped_lock + { + private: + + std::mutex & m_; + + scoped_lock(scoped_lock const &); + scoped_lock & operator=(scoped_lock const &); + + public: + + scoped_lock( lightweight_mutex & m ): m_( m.m_ ) + { + m_.lock(); + } + + ~scoped_lock() + { + m_.unlock(); + } + }; +}; + +} // namespace detail + +} // namespace boost + +#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_STD_MUTEX_HPP_INCLUDED