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
33 #ifndef BOOST_USE_WINDOWS_H
35 struct critical_section
37 struct critical_section_debug * DebugInfo;
43 unsigned __int64 SpinCount;
45 unsigned long SpinCount;
49 #if BOOST_PLAT_WINDOWS_RUNTIME
50 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSectionEx(critical_section *, unsigned long, unsigned long);
52 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *);
54 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *);
55 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *);
56 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *);
60 typedef ::CRITICAL_SECTION critical_section;
62 #endif // #ifndef BOOST_USE_WINDOWS_H
64 class lightweight_mutex
70 lightweight_mutex(lightweight_mutex const &);
71 lightweight_mutex & operator=(lightweight_mutex const &);
77 #if BOOST_PLAT_WINDOWS_RUNTIME
78 InitializeCriticalSectionEx(&cs_, 4000, 0);
80 InitializeCriticalSection(&cs_);
86 DeleteCriticalSection(&cs_);
90 friend class scoped_lock;
96 lightweight_mutex & m_;
98 scoped_lock(scoped_lock const &);
99 scoped_lock & operator=(scoped_lock const &);
103 explicit scoped_lock(lightweight_mutex & m): m_(m)
105 EnterCriticalSection(&m_.cs_);
110 LeaveCriticalSection(&m_.cs_);
115 } // namespace detail
119 #endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED