8#ifndef INCLUDED_BSLMT_MUTEXIMPL_WIN32
9#define INCLUDED_BSLMT_MUTEXIMPL_WIN32
68#include <bslscm_version.h>
74#ifdef BSLMT_PLATFORM_WIN32_THREADS
81struct _RTL_CRITICAL_SECTION;
83typedef struct _RTL_CRITICAL_SECTION CRITICAL_SECTION, *LPCRITICAL_SECTION;
85typedef unsigned long DWORD;
88 __declspec(dllimport) BOOL __stdcall InitializeCriticalSectionAndSpinCount(
89 LPCRITICAL_SECTION lpCriticalSection,
92 __declspec(dllimport)
void __stdcall DeleteCriticalSection(
93 LPCRITICAL_SECTION lpCriticalSection);
95 __declspec(dllimport) BOOL __stdcall TryEnterCriticalSection(
96 LPCRITICAL_SECTION lpCriticalSection);
98 __declspec(dllimport)
void __stdcall EnterCriticalSection(
99 LPCRITICAL_SECTION lpCriticalSection);
101 __declspec(dllimport)
void __stdcall LeaveCriticalSection(
102 LPCRITICAL_SECTION lpCriticalSection);
109template <
class THREAD_POLICY>
122class MutexImpl<Platform::Win32Threads> {
130#ifdef BSLS_PLATFORM_CPU_64_BIT
132 k_CRITICAL_SECTION_BUFFER_SIZE = 5
135 k_CRITICAL_SECTION_BUFFER_SIZE = 6
149 void *d_lock[k_CRITICAL_SECTION_BUFFER_SIZE];
152 MutexImpl(
const MutexImpl&);
153 MutexImpl& operator=(
const MutexImpl&);
160 typedef _RTL_CRITICAL_SECTION NativeType;
182 NativeType& nativeMutex();
205MutexImpl<bslmt::Platform::Win32Threads>::MutexImpl()
207 InitializeCriticalSectionAndSpinCount(
208 reinterpret_cast<_RTL_CRITICAL_SECTION *
>(d_lock), k_SPIN_COUNT);
212MutexImpl<bslmt::Platform::Win32Threads>::~MutexImpl()
214 DeleteCriticalSection(
215 reinterpret_cast<_RTL_CRITICAL_SECTION*
>(d_lock));
220void MutexImpl<bslmt::Platform::Win32Threads>::lock()
222 EnterCriticalSection(
223 reinterpret_cast<_RTL_CRITICAL_SECTION*
>(d_lock));
227MutexImpl<bslmt::Platform::Win32Threads>::NativeType&
228MutexImpl<bslmt::Platform::Win32Threads>::nativeMutex()
230 return *
reinterpret_cast<_RTL_CRITICAL_SECTION*
>(d_lock);
234int MutexImpl<bslmt::Platform::Win32Threads>::tryLock()
236 return !TryEnterCriticalSection(
237 reinterpret_cast<_RTL_CRITICAL_SECTION*
>(d_lock));
241void MutexImpl<bslmt::Platform::Win32Threads>::unlock()
243 LeaveCriticalSection(
244 reinterpret_cast<_RTL_CRITICAL_SECTION*
>(d_lock));
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslmt_barrier.h:344