aboutsummaryrefslogtreecommitdiffstats
path: root/common/threads.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-06-28 12:48:41 -0700
committerChris Robinson <[email protected]>2020-06-28 12:55:55 -0700
commitf81558c948e8dbc044176443c2455f6e2f3b5e08 (patch)
tree0da21d22244aefc40abb1ca5e02389272f6f84de /common/threads.cpp
parent31791c9997d06a3a315d2b936515f643430cd5e9 (diff)
Avoid including windows.h in threads.h
Diffstat (limited to 'common/threads.cpp')
-rw-r--r--common/threads.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/threads.cpp b/common/threads.cpp
index ff01de42..e3b715f0 100644
--- a/common/threads.cpp
+++ b/common/threads.cpp
@@ -20,12 +20,15 @@
#include "config.h"
+#include "opthelpers.h"
#include "threads.h"
#include <system_error>
#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
#include <limits>
@@ -73,15 +76,15 @@ semaphore::~semaphore()
void semaphore::post()
{
- if(!ReleaseSemaphore(mSem, 1, nullptr))
+ if UNLIKELY(!ReleaseSemaphore(static_cast<HANDLE>(mSem), 1, nullptr))
throw std::system_error(std::make_error_code(std::errc::value_too_large));
}
void semaphore::wait() noexcept
-{ WaitForSingleObject(mSem, INFINITE); }
+{ WaitForSingleObject(static_cast<HANDLE>(mSem), INFINITE); }
bool semaphore::try_wait() noexcept
-{ return WaitForSingleObject(mSem, 0) == WAIT_OBJECT_0; }
+{ return WaitForSingleObject(static_cast<HANDLE>(mSem), 0) == WAIT_OBJECT_0; }
} // namespace al