8#ifndef INCLUDED_BSLMT_TIMEDSEMAPHOREIMPL_WIN32
9#define INCLUDED_BSLMT_TIMEDSEMAPHOREIMPL_WIN32
85#include <bslscm_version.h>
89#ifdef BSLMT_PLATFORM_WIN32_THREADS
97#include <bsl_c_limits.h>
99struct _SECURITY_ATTRIBUTES;
100typedef struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
101typedef struct _SECURITY_ATTRIBUTES *LPSECURITY_ATTRIBUTES;
102typedef long LONG, *LPLONG;
105typedef const char *LPCSTR;
106typedef unsigned long DWORD;
110 __declspec(dllimport) HANDLE __stdcall CreateSemaphoreA(
111 LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
117 __declspec(dllimport) BOOL __stdcall CloseHandle(
121 __declspec(dllimport) BOOL __stdcall ReleaseSemaphore(
124 LPLONG lpPreviousCount
127 __declspec(dllimport) DWORD __stdcall WaitForSingleObject(
137template <
class TIMED_SEMAPHORE_POLICY>
138class TimedSemaphoreImpl;
146class TimedSemaphoreImpl<Platform::Win32TimedSemaphore> {
156 TimedSemaphoreImpl(
const TimedSemaphoreImpl&);
157 TimedSemaphoreImpl& operator=(
const TimedSemaphoreImpl&);
163 enum { e_TIMED_OUT = 0x102 };
188 TimedSemaphoreImpl(
int count,
193 ~TimedSemaphoreImpl();
203 void post(
int number);
239TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
241: d_clockType(clockType)
243 d_handle = CreateSemaphoreA(NULL, 0, INT_MAX, NULL);
244 if (NULL == d_handle) {
250TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
252: d_clockType(clockType)
254 d_handle = CreateSemaphoreA(NULL, count, INT_MAX, NULL);
255 if (NULL == d_handle) {
261TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
262 ~TimedSemaphoreImpl()
264 CloseHandle(d_handle);
269void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::post()
271 ReleaseSemaphore(d_handle, 1, NULL);
275void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
278 ReleaseSemaphore(d_handle, number, NULL);
282int TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::tryWait()
284 return WaitForSingleObject(d_handle, 0);
288void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::wait()
290 WaitForSingleObject(d_handle, 0xFFFFFFFF );
296TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
Definition bsls_timeinterval.h:301
#define BSLS_ASSERT_INVOKE_NORETURN(X)
Definition bsls_assert.h:1895
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslmt_barrier.h:344
Enum
Definition bsls_systemclocktype.h:117
@ e_REALTIME
Definition bsls_systemclocktype.h:120