2 // detail/win_mutex.hpp
3 // ~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_WIN_MUTEX_HPP
12 #define BOOST_ASIO_DETAIL_WIN_MUTEX_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_WINDOWS)
22 #include <boost/asio/detail/noncopyable.hpp>
23 #include <boost/asio/detail/scoped_lock.hpp>
24 #include <boost/asio/detail/socket_types.hpp>
26 #include <boost/asio/detail/push_options.hpp>
36 typedef boost::asio::detail::scoped_lock<win_mutex> scoped_lock;
39 BOOST_ASIO_DECL win_mutex();
44 ::DeleteCriticalSection(&crit_section_);
50 ::EnterCriticalSection(&crit_section_);
56 ::LeaveCriticalSection(&crit_section_);
60 // Initialisation must be performed in a separate function to the constructor
61 // since the compiler does not support the use of structured exceptions and
62 // C++ exceptions in the same function.
63 BOOST_ASIO_DECL int do_init();
65 ::CRITICAL_SECTION crit_section_;
72 #include <boost/asio/detail/pop_options.hpp>
74 #if defined(BOOST_ASIO_HEADER_ONLY)
75 # include <boost/asio/detail/impl/win_mutex.ipp>
76 #endif // defined(BOOST_ASIO_HEADER_ONLY)
78 #endif // defined(BOOST_ASIO_WINDOWS)
80 #endif // BOOST_ASIO_DETAIL_WIN_MUTEX_HPP