123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
- #define BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
- #include <boost/config.hpp>
- #if defined(BOOST_SYSTEM_DISABLE_THREADS)
- namespace boost
- {
- namespace system
- {
- namespace detail
- {
- struct mutex
- {
- void lock()
- {
- }
- void unlock()
- {
- }
- };
- }
- }
- }
- #else
- #if defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140
- #include <boost/winapi/config.hpp>
- #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
- #include <shared_mutex>
- #if BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
- # define BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX
- #endif
- #endif
- #endif
- #if defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
- namespace boost
- {
- namespace system
- {
- namespace detail
- {
- typedef std::shared_mutex mutex;
- }
- }
- }
- #else
- #include <mutex>
- namespace boost
- {
- namespace system
- {
- namespace detail
- {
- using std::mutex;
- }
- }
- }
- #endif
- #endif
- namespace boost
- {
- namespace system
- {
- namespace detail
- {
- template<class Mtx> class lock_guard
- {
- private:
- Mtx& mtx_;
- private:
- lock_guard( lock_guard const& );
- lock_guard& operator=( lock_guard const& );
- public:
- explicit lock_guard( Mtx& mtx ): mtx_( mtx )
- {
- mtx_.lock();
- }
- ~lock_guard()
- {
- mtx_.unlock();
- }
- };
- }
- }
- }
- #endif
|