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> {
157 TimedSemaphoreImpl(
const TimedSemaphoreImpl&);
158 TimedSemaphoreImpl& operator=(
const TimedSemaphoreImpl&);
164 enum { e_TIMED_OUT = 0x102 };
189 TimedSemaphoreImpl(
int count,
194 ~TimedSemaphoreImpl();
205 void post(
int number);
241TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
243: d_clockType(clockType)
245 d_handle = CreateSemaphoreA(NULL, 0, INT_MAX, NULL);
246 if (NULL == d_handle) {
252TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
254: d_clockType(clockType)
256 d_handle = CreateSemaphoreA(NULL, count, INT_MAX, NULL);
257 if (NULL == d_handle) {
263TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
264 ~TimedSemaphoreImpl()
266 CloseHandle(d_handle);
271void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::post()
273 ReleaseSemaphore(d_handle, 1, NULL);
277void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
280 ReleaseSemaphore(d_handle, number, NULL);
284int TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::tryWait()
286 return WaitForSingleObject(d_handle, 0);
290void TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::wait()
292 WaitForSingleObject(d_handle, 0xFFFFFFFF );
298TimedSemaphoreImpl<bslmt::Platform::Win32TimedSemaphore>::
Definition bsls_timeinterval.h:307
#define BSLS_ASSERT_INVOKE_NORETURN(X)
Definition bsls_assert.h:2101
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bslmt_barrier.h:344
Enum
Definition bsls_systemclocktype.h:119
@ e_REALTIME
Definition bsls_systemclocktype.h:122