2 // detail/win_static_mutex.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 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_STATIC_MUTEX_HPP
12 #define BOOST_ASIO_DETAIL_WIN_STATIC_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/scoped_lock.hpp>
24 #include <boost/asio/detail/push_options.hpp>
30 struct win_static_mutex
32 typedef boost::asio::detail::scoped_lock<win_static_mutex> scoped_lock;
34 // Initialise the mutex.
35 BOOST_ASIO_DECL void init();
37 // Initialisation must be performed in a separate function to the "public"
38 // init() function since the compiler does not support the use of structured
39 // exceptions and C++ exceptions in the same function.
40 BOOST_ASIO_DECL int do_init();
45 ::EnterCriticalSection(&crit_section_);
51 ::LeaveCriticalSection(&crit_section_);
55 ::CRITICAL_SECTION crit_section_;
59 # define BOOST_ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0 } }
60 #else // defined(UNDER_CE)
61 # define BOOST_ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0, 0 } }
62 #endif // defined(UNDER_CE)
68 #include <boost/asio/detail/pop_options.hpp>
70 #if defined(BOOST_ASIO_HEADER_ONLY)
71 # include <boost/asio/detail/impl/win_static_mutex.ipp>
72 #endif // defined(BOOST_ASIO_HEADER_ONLY)
74 #endif // defined(BOOST_ASIO_WINDOWS)
76 #endif // BOOST_ASIO_DETAIL_WIN_STATIC_MUTEX_HPP