mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-01 05:34:36 +02:00
Remove lwm_nop.hpp; add lwm_std_mutex.hpp
This commit is contained in:
@@ -28,15 +28,12 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#if !defined(BOOST_HAS_THREADS)
|
#if !defined(BOOST_NO_CXX11_HDR_MUTEX )
|
||||||
# include <boost/smart_ptr/detail/lwm_nop.hpp>
|
# include <boost/smart_ptr/detail/lwm_std_mutex.hpp>
|
||||||
#elif defined(BOOST_HAS_PTHREADS)
|
#elif defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
# include <boost/smart_ptr/detail/lwm_pthreads.hpp>
|
|
||||||
#elif defined(BOOST_HAS_WINTHREADS) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
|
||||||
# include <boost/smart_ptr/detail/lwm_win32_cs.hpp>
|
# include <boost/smart_ptr/detail/lwm_win32_cs.hpp>
|
||||||
#else
|
#else
|
||||||
// Use #define BOOST_DISABLE_THREADS to avoid the error
|
# include <boost/smart_ptr/detail/lwm_pthreads.hpp>
|
||||||
# error Unrecognized threading platform
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
|
#endif // #ifndef BOOST_SMART_PTR_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
|
||||||
|
@@ -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
|
|
62
include/boost/smart_ptr/detail/lwm_std_mutex.hpp
Normal file
62
include/boost/smart_ptr/detail/lwm_std_mutex.hpp
Normal file
@@ -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 <boost/assert.hpp>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
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
|
Reference in New Issue
Block a user