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 *);
53 typedef ::CRITICAL_SECTION critical_section;
55 #endif // #ifndef BOOST_USE_WINDOWS_H
57 class lightweight_mutex
63 lightweight_mutex(lightweight_mutex const &);
64 lightweight_mutex & operator=(lightweight_mutex const &);
70 InitializeCriticalSection(&cs_);
75 DeleteCriticalSection(&cs_);
79 friend class scoped_lock;
85 lightweight_mutex & m_;
87 scoped_lock(scoped_lock const &);
88 scoped_lock & operator=(scoped_lock const &);
92 explicit scoped_lock(lightweight_mutex & m): m_(m)
94 EnterCriticalSection(&m_.cs_);
99 LeaveCriticalSection(&m_.cs_);
104 } // namespace detail
108 #endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED