1 #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
2 #define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // boost/detail/lwm_win32_cs.hpp
13 // Copyright (c) 2002, 2003 Peter Dimov
14 // Copyright (c) Microsoft Corporation 2014
16 // Distributed under the Boost Software License, Version 1.0. (See
17 // accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
21 #include <boost/predef.h>
23 #ifdef BOOST_USE_WINDOWS_H
29 struct _RTL_CRITICAL_SECTION;
39 #ifndef BOOST_USE_WINDOWS_H
41 struct critical_section
43 struct critical_section_debug * DebugInfo;
49 unsigned __int64 SpinCount;
51 unsigned long SpinCount;
55 #if BOOST_PLAT_WINDOWS_RUNTIME
56 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(::_RTL_CRITICAL_SECTION *, unsigned long, unsigned long);
58 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);
60 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *);
61 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
62 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
64 typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
66 #else // #ifndef BOOST_USE_WINDOWS_H
68 typedef ::CRITICAL_SECTION critical_section;
70 #if BOOST_PLAT_WINDOWS_RUNTIME
71 using ::InitializeCriticalSectionEx;
73 using ::InitializeCriticalSection;
75 using ::EnterCriticalSection;
76 using ::LeaveCriticalSection;
77 using ::DeleteCriticalSection;
79 typedef ::CRITICAL_SECTION rtl_critical_section;
81 #endif // #ifndef BOOST_USE_WINDOWS_H
83 class lightweight_mutex
89 lightweight_mutex(lightweight_mutex const &);
90 lightweight_mutex & operator=(lightweight_mutex const &);
96 #if BOOST_PLAT_WINDOWS_RUNTIME
97 boost::detail::InitializeCriticalSectionEx(reinterpret_cast< rtl_critical_section* >(&cs_), 4000, 0);
99 boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
105 boost::detail::DeleteCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
109 friend class scoped_lock;
115 lightweight_mutex & m_;
117 scoped_lock(scoped_lock const &);
118 scoped_lock & operator=(scoped_lock const &);
122 explicit scoped_lock(lightweight_mutex & m): m_(m)
124 boost::detail::EnterCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
129 boost::detail::LeaveCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
134 } // namespace detail
138 #endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED