1 #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
2 #define BOOST_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
15 // Distributed under the Boost Software License, Version 1.0. (See
16 // accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifdef BOOST_USE_WINDOWS_H
30 #ifndef BOOST_USE_WINDOWS_H
32 struct CRITICAL_SECTION
34 struct critical_section_debug * DebugInfo;
40 unsigned __int64 SpinCount;
42 unsigned long SpinCount;
46 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
47 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
48 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
49 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
51 #endif // #ifndef BOOST_USE_WINDOWS_H
53 class lightweight_mutex
59 lightweight_mutex(lightweight_mutex const &);
60 lightweight_mutex & operator=(lightweight_mutex const &);
66 InitializeCriticalSection(&cs_);
71 DeleteCriticalSection(&cs_);
75 friend class scoped_lock;
81 lightweight_mutex & m_;
83 scoped_lock(scoped_lock const &);
84 scoped_lock & operator=(scoped_lock const &);
88 explicit scoped_lock(lightweight_mutex & m): m_(m)
90 EnterCriticalSection(&m_.cs_);
95 LeaveCriticalSection(&m_.cs_);
100 } // namespace detail
104 #endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED