1 #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
2 #define BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
9 // boost/detail/lwm_win32_cs.hpp
11 // Copyright (c) 2002, 2003 Peter Dimov
13 // Permission to copy, use, modify, sell and distribute this software
14 // is granted provided this copyright notice appears in all copies.
15 // This software is provided "as is" without express or implied
16 // warranty, and with no claim as to its suitability for any purpose.
19 #ifdef BOOST_USE_WINDOWS_H
29 #ifndef BOOST_USE_WINDOWS_H
31 struct CRITICAL_SECTION
33 struct critical_section_debug * DebugInfo;
39 unsigned __int64 SpinCount;
41 unsigned long SpinCount;
45 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(CRITICAL_SECTION *);
46 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(CRITICAL_SECTION *);
47 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(CRITICAL_SECTION *);
48 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(CRITICAL_SECTION *);
50 #endif // #ifndef BOOST_USE_WINDOWS_H
52 class lightweight_mutex
58 lightweight_mutex(lightweight_mutex const &);
59 lightweight_mutex & operator=(lightweight_mutex const &);
65 InitializeCriticalSection(&cs_);
70 DeleteCriticalSection(&cs_);
74 friend class scoped_lock;
80 lightweight_mutex & m_;
82 scoped_lock(scoped_lock const &);
83 scoped_lock & operator=(scoped_lock const &);
87 explicit scoped_lock(lightweight_mutex & m): m_(m)
89 EnterCriticalSection(&m_.cs_);
94 LeaveCriticalSection(&m_.cs_);
103 #endif // #ifndef BOOST_DETAIL_LWM_WIN32_CS_HPP_INCLUDED