1 #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
\r
2 #define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
\r
4 // MS compatible compilers support #pragma once
\r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
\r
11 // boost/detail/lwm_win32_cs.hpp
\r
13 // Copyright (c) 2002, 2003 Peter Dimov
\r
15 // Distributed under the Boost Software License, Version 1.0. (See
\r
16 // accompanying file LICENSE_1_0.txt or copy at
\r
17 // http://www.boost.org/LICENSE_1_0.txt)
\r
20 #ifdef BOOST_USE_WINDOWS_H
\r
21 # include <windows.h>
\r
30 #ifndef BOOST_USE_WINDOWS_H
\r
32 struct critical_section
\r
34 struct critical_section_debug * DebugInfo;
\r
36 long RecursionCount;
\r
37 void * OwningThread;
\r
38 void * LockSemaphore;
\r
40 unsigned __int64 SpinCount;
\r
42 unsigned long SpinCount;
\r
46 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *);
\r
47 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *);
\r
48 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *);
\r
49 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *);
\r
53 typedef ::CRITICAL_SECTION critical_section;
\r
55 #endif // #ifndef BOOST_USE_WINDOWS_H
\r
57 class lightweight_mutex
\r
61 critical_section cs_;
\r
63 lightweight_mutex(lightweight_mutex const &);
\r
64 lightweight_mutex & operator=(lightweight_mutex const &);
\r
70 InitializeCriticalSection(&cs_);
\r
73 ~lightweight_mutex()
\r
75 DeleteCriticalSection(&cs_);
\r
79 friend class scoped_lock;
\r
85 lightweight_mutex & m_;
\r
87 scoped_lock(scoped_lock const &);
\r
88 scoped_lock & operator=(scoped_lock const &);
\r
92 explicit scoped_lock(lightweight_mutex & m): m_(m)
\r
94 EnterCriticalSection(&m_.cs_);
\r
99 LeaveCriticalSection(&m_.cs_);
\r
104 } // namespace detail
\r
106 } // namespace boost
\r
108 #endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
\r