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 // Permission to copy, use, modify, sell and distribute this software
16 // is granted provided this copyright notice appears in all copies.
17 // This software is provided "as is" without express or implied
18 // warranty, and with no claim as to its suitability for any purpose.
21 #ifdef BOOST_USE_WINDOWS_H
31 #ifndef BOOST_USE_WINDOWS_H
33 struct CRITICAL_SECTION
35 struct critical_section_debug * DebugInfo;
41 unsigned __int64 SpinCount;
43 unsigned long SpinCount;
47 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
48 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
49 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
50 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
52 #endif // #ifndef BOOST_USE_WINDOWS_H
54 class lightweight_mutex
60 lightweight_mutex(lightweight_mutex const &);
61 lightweight_mutex & operator=(lightweight_mutex const &);
67 InitializeCriticalSection(&cs_);
72 DeleteCriticalSection(&cs_);
76 friend class scoped_lock;
82 lightweight_mutex & m_;
84 scoped_lock(scoped_lock const &);
85 scoped_lock & operator=(scoped_lock const &);
89 explicit scoped_lock(lightweight_mutex & m): m_(m)
91 EnterCriticalSection(&m_.cs_);
96 LeaveCriticalSection(&m_.cs_);
101 } // namespace detail
105 #endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED