libcruft-util/thread/thread_win32.cpp
Danny Robson 01094611eb thread: add minimal thread primitives for win32
This allows us to get around the lack of these types under MinGW
2019-06-22 15:46:34 +10:00

48 lines
1.1 KiB
C++

#include "thread_win32.hpp"
using cruft::thread::win32::thread;
///////////////////////////////////////////////////////////////////////////////
thread::thread () noexcept
{ ; }
//-----------------------------------------------------------------------------
thread::thread (thread &&rhs) noexcept
{
std::swap (m_handle, rhs.m_handle);
}
//-----------------------------------------------------------------------------
thread&
thread::operator= (thread &&rhs) noexcept
{
std::swap (m_handle, rhs.m_handle);
return *this;
}
///////////////////////////////////////////////////////////////////////////////
void thread::join ()
{
WaitForSingleObject (m_handle, INFINITE);
}
///////////////////////////////////////////////////////////////////////////////
unsigned int thread::hardware_concurrency (void) noexcept
{
SYSTEM_INFO res;
GetNativeSystemInfo (&res);
return res.dwNumberOfProcessors;
}
///////////////////////////////////////////////////////////////////////////////
void cruft::thread::win32::this_thread::yield (void) noexcept
{
Sleep (0);
}