From 6488028a2230de25d8c63eff351df8af100618ae Mon Sep 17 00:00:00 2001 From: Steve Gates Date: Tue, 8 Jul 2014 14:53:39 -0700 Subject: [PATCH] Incorporating feedback: removed copyright, removed some ifdefs. --- include/boost/thread/detail/thread.hpp | 1 - .../boost/thread/win32/basic_timed_mutex.hpp | 13 -- .../boost/thread/win32/condition_variable.hpp | 5 - include/boost/thread/win32/once.hpp | 115 +----------------- include/boost/thread/win32/shared_mutex.hpp | 27 ---- include/boost/thread/win32/thread_data.hpp | 5 - .../boost/thread/win32/thread_primitives.hpp | 83 +++++++++---- src/win32/thread.cpp | 42 +------ test/test_2741.cpp | 1 - test/test_tss.cpp | 1 - 10 files changed, 70 insertions(+), 223 deletions(-) diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 8cfb92b1..73f3cc5c 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -1,6 +1,5 @@ // (C) Copyright 2007-2010 Anthony Williams // (C) Copyright 20011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/thread/win32/basic_timed_mutex.hpp b/include/boost/thread/win32/basic_timed_mutex.hpp index 7f599c99..b55affdc 100644 --- a/include/boost/thread/win32/basic_timed_mutex.hpp +++ b/include/boost/thread/win32/basic_timed_mutex.hpp @@ -5,7 +5,6 @@ // // (C) Copyright 2006-8 Anthony Williams // (C) Copyright 2011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -82,11 +81,7 @@ namespace boost do { -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - unsigned const retval(win32::WaitForSingleObject(sem, ::boost::detail::win32::infinite)); -#else unsigned const retval(win32::WaitForSingleObjectEx(sem, ::boost::detail::win32::infinite,0)); -#endif BOOST_VERIFY(0 == retval || ::boost::detail::win32::wait_abandoned == retval); // BOOST_VERIFY(win32::WaitForSingleObject( // sem,::boost::detail::win32::infinite)==0); @@ -147,11 +142,7 @@ namespace boost do { -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - if(win32::WaitForSingleObject(sem,::boost::detail::get_milliseconds_until(wait_until))!=0) -#else if(win32::WaitForSingleObjectEx(sem,::boost::detail::get_milliseconds_until(wait_until),0)!=0) -#endif { BOOST_INTERLOCKED_DECREMENT(&active_count); return false; @@ -214,11 +205,7 @@ namespace boost { chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - if(win32::WaitForSingleObject(sem,static_cast(rel_time.count()))!=0) -#else if(win32::WaitForSingleObjectEx(sem,static_cast(rel_time.count()),0)!=0) -#endif { BOOST_INTERLOCKED_DECREMENT(&active_count); return false; diff --git a/include/boost/thread/win32/condition_variable.hpp b/include/boost/thread/win32/condition_variable.hpp index a1d58f4a..c2c6ee7d 100644 --- a/include/boost/thread/win32/condition_variable.hpp +++ b/include/boost/thread/win32/condition_variable.hpp @@ -3,7 +3,6 @@ // (C) Copyright 2007-8 Anthony Williams // (C) Copyright 2011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -98,11 +97,7 @@ namespace boost bool woken() { -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - unsigned long const woken_result=detail::win32::WaitForSingleObject(wake_sem,0); -#else unsigned long const woken_result=detail::win32::WaitForSingleObjectEx(wake_sem,0,0); -#endif BOOST_ASSERT((woken_result==detail::win32::timeout) || (woken_result==0)); return woken_result==0; } diff --git a/include/boost/thread/win32/once.hpp b/include/boost/thread/win32/once.hpp index e8ee6940..c3398f6a 100644 --- a/include/boost/thread/win32/once.hpp +++ b/include/boost/thread/win32/once.hpp @@ -6,7 +6,6 @@ // (C) Copyright 2005-7 Anthony Williams // (C) Copyright 2005 John Maddock // (C) Copyright 2011-2013 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -153,27 +152,11 @@ namespace boost { name_once_mutex(mutex_name,flag_address); } -#if !defined(BOOST_NO_ANSI_APIS) - return ::boost::detail::win32::CreateEventA( - 0, + + return ::boost::detail::win32::create_event( + mutex_name, ::boost::detail::win32::manual_reset_event, - ::boost::detail::win32::event_initially_reset, - mutex_name); -#else -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - return ::boost::detail::win32::CreateEventW( - 0, - ::boost::detail::win32::manual_reset_event, - ::boost::detail::win32::event_initially_reset, - mutex_name); -#else - return ::boost::detail::win32::CreateEventExW( - 0, - mutex_name, - ::boost::detail::win32::create_event_manual_reset, - ::boost::detail::win32::event_all_access); -#endif -#endif + ::boost::detail::win32::event_initially_reset); } struct once_context { @@ -281,13 +264,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite, 0)); -# endif } } //#endif @@ -330,13 +308,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -382,13 +355,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } #else @@ -432,13 +400,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -480,13 +443,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -528,13 +486,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -576,13 +529,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } #elif defined BOOST_NO_CXX11_RVALUE_REFERENCES @@ -626,13 +574,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -674,13 +617,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -770,13 +708,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } #endif @@ -820,13 +753,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -870,13 +798,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -921,13 +844,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -973,13 +891,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } #endif @@ -1022,13 +935,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } @@ -1074,13 +982,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -1126,13 +1029,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } template @@ -1180,13 +1078,8 @@ namespace boost continue; } } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObject( - ctx.event_handle,::boost::detail::win32::infinite)); -# else BOOST_VERIFY(!::boost::detail::win32::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); -# endif } } diff --git a/include/boost/thread/win32/shared_mutex.hpp b/include/boost/thread/win32/shared_mutex.hpp index 26d28054..1d5c2000 100644 --- a/include/boost/thread/win32/shared_mutex.hpp +++ b/include/boost/thread/win32/shared_mutex.hpp @@ -3,7 +3,6 @@ // (C) Copyright 2006-8 Anthony Williams // (C) Copyright 2011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -185,11 +184,7 @@ namespace boost return true; } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - unsigned long const res=detail::win32::WaitForSingleObject(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until)); -# else unsigned long const res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until), 0); -# endif if(res==detail::win32::timeout) { for(;;) @@ -294,13 +289,8 @@ namespace boost unsigned long res; if (tp>n) { chrono::milliseconds rel_time= chrono::ceil(tp-n); -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - res=detail::win32::WaitForSingleObject(semaphores[unlock_sem], - static_cast(rel_time.count())); -# else res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem], static_cast(rel_time.count()), 0); -# endif } else { res=detail::win32::timeout; } @@ -476,11 +466,7 @@ namespace boost #else const bool wait_all = false; #endif -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WS03 - unsigned long const wait_res=detail::win32::WaitForMultipleObjects(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until)); -# else unsigned long const wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until), 0); -# endif if(wait_res==detail::win32::timeout) { for(;;) @@ -592,13 +578,8 @@ namespace boost unsigned long wait_res; if (tp>n) { chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WS03 - wait_res=detail::win32::WaitForMultipleObjects(2,semaphores,wait_all, - static_cast(rel_time.count())); -# else wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all, static_cast(rel_time.count()), 0); -# endif } else { wait_res=detail::win32::timeout; } @@ -709,11 +690,7 @@ namespace boost return; } -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!detail::win32::WaitForSingleObject(semaphores[unlock_sem],detail::win32::infinite)); -# else BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],detail::win32::infinite, 0)); -# endif } } @@ -802,11 +779,7 @@ namespace boost { if(!last_reader) { -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - BOOST_VERIFY(!detail::win32::WaitForSingleObject(upgrade_sem,detail::win32::infinite)); -# else BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(upgrade_sem,detail::win32::infinite, 0)); -# endif } break; } diff --git a/include/boost/thread/win32/thread_data.hpp b/include/boost/thread/win32/thread_data.hpp index 8b8ac209..017ded0f 100644 --- a/include/boost/thread/win32/thread_data.hpp +++ b/include/boost/thread/win32/thread_data.hpp @@ -1,6 +1,5 @@ // (C) Copyright 2008 Anthony Williams // (C) Copyright 2011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -127,11 +126,7 @@ namespace boost thread_data_base(): count(0), -#if BOOST_PLAT_WINDOWS_RUNTIME thread_handle(), -#else - thread_handle(detail::win32::invalid_handle_value), -#endif id(0), thread_exit_callbacks(0), tss_data(), diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index 761fa1cc..ced1bdc3 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -5,7 +5,6 @@ // // (C) Copyright 2005-7 Anthony Williams // (C) Copyright 2007 David Deakins -// (C) Copyright 2014 Microsoft Corporation // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -70,18 +69,18 @@ namespace boost using ::OpenEventA; using ::CreateSemaphoreA; # endif +#if BOOST_PLAT_WINDOWS_RUNTIME + using ::GetNativeSystemInfo; +#else + using ::GetSystemInfo; +#endif using ::CloseHandle; using ::ReleaseMutex; using ::ReleaseSemaphore; using ::SetEvent; using ::ResetEvent; -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - using ::WaitForMultipleObjects; - using ::WaitForSingleObject; -# else using ::WaitForMultipleObjectsEx; using ::WaitForSingleObjectEx; -# endif using ::GetCurrentProcessId; using ::GetCurrentThreadId; using ::GetCurrentThread; @@ -157,6 +156,7 @@ namespace boost extern "C" { struct _SECURITY_ATTRIBUTES; + struct SYSTEM_INFO; # ifdef BOOST_NO_ANSI_APIS # if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA __declspec(dllimport) void* __stdcall CreateMutexW(_SECURITY_ATTRIBUTES*,int,wchar_t const*); @@ -174,15 +174,15 @@ namespace boost __declspec(dllimport) void* __stdcall CreateEventA(_SECURITY_ATTRIBUTES*,int,int,char const*); __declspec(dllimport) void* __stdcall OpenEventA(unsigned long,int,char const*); # endif +#if BOOST_PLAT_WINDOWS_RUNTIME + __declspec(dllimport) void __stdcall GetNativeSystemInfo(SYSTEM_INFO*); +#else + __declspec(dllimport) void __stdcall GetSystemInfo(SYSTEM_INFO*); +#endif __declspec(dllimport) int __stdcall CloseHandle(void*); __declspec(dllimport) int __stdcall ReleaseMutex(void*); -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - __declspec(dllimport) unsigned long __stdcall WaitForSingleObject(void*,unsigned long); - __declspec(dllimport) unsigned long __stdcall WaitForMultipleObjects(unsigned long nCount,void* const * lpHandles,int bWaitAll,unsigned long dwMilliseconds); -# else __declspec(dllimport) unsigned long __stdcall WaitForSingleObjectEx(void*,unsigned long,int); __declspec(dllimport) unsigned long __stdcall WaitForMultipleObjectsEx(unsigned long nCount,void* const * lpHandles,int bWaitAll,unsigned long dwMilliseconds,int bAlertable); -# endif __declspec(dllimport) int __stdcall ReleaseSemaphore(void*,long,long*); __declspec(dllimport) int __stdcall DuplicateHandle(void*,void*,void*,void**,unsigned long,int,unsigned long); #if !BOOST_PLAT_WINDOWS_RUNTIME @@ -242,21 +242,32 @@ namespace boost event_initially_set=true }; - inline handle create_anonymous_event(event_type type,initial_event_state state) + inline handle create_event( +#if !defined(BOOST_NO_ANSI_APIS) + const char *mutex_name, +#else + const wchar_t *mutex_name, +#endif + event_type type, + initial_event_state state) { #if !defined(BOOST_NO_ANSI_APIS) - handle const res=win32::CreateEventA(0,type,state,0); -#else -#if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - handle const res=win32::CreateEventW(0,type,state,0); + handle const res = win32::CreateEventA(0, type, state, mutex_name); +#elif BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA + handle const res = win32::CreateEventW(0, type, state, mutex_name); #else - handle const res=win32::CreateEventExW( - 0, - 0, + handle const res = win32::CreateEventExW( + 0, + mutex_name, type ? create_event_manual_reset : 0 | state ? create_event_initial_set : 0, - event_all_access); -#endif + event_all_access); #endif + return res; + } + + inline handle create_anonymous_event(event_type type,initial_event_state state) + { + handle const res = create_event(0, type, state); if(!res) { boost::throw_exception(thread_resource_error()); @@ -305,6 +316,36 @@ namespace boost { BOOST_VERIFY(ReleaseSemaphore(semaphore,count,0)!=0); } + + inline void get_system_info(SYSTEM_INFO *info) + { +#if BOOST_PLAT_WINDOWS_RUNTIME + GetNativeSystemInfo(info); +#else + GetSystemInfo(info); +#endif + } + + inline void sleep(unsigned long milliseconds) + { + if(milliseconds == 0) + { +#if BOOST_PLAT_WINDOWS_RUNTIME + std::this_thread::yield(); +#else + detail::win32::Sleep(0); +#endif + } + else + { +#if BOOST_PLAT_WINDOWS_RUNTIME + detail::win32::WaitForSingleObjectEx(detail::win32::GetCurrentThread(), milliseconds, FALSE); +#else + detail::win32::Sleep(milliseconds); +#endif + } + } + #if BOOST_PLAT_WINDOWS_RUNTIME class BOOST_THREAD_DECL scoped_winrt_thread { diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index cc864974..63c1b04a 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -1,7 +1,6 @@ // (C) Copyright 2007 Anthony Williams // (C) Copyright 2007 David Deakins // (C) Copyright 2011-2012 Vicente J. Botet Escriba -// (C) Copyright 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -531,24 +530,15 @@ namespace boost bool thread::interruption_requested() const BOOST_NOEXCEPT { detail::thread_data_ptr local_thread_info=(get_thread_info)(); -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - return local_thread_info.get() && (detail::win32::WaitForSingleObject(local_thread_info->interruption_handle,0)==0); -# else return local_thread_info.get() && (detail::win32::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0); -# endif } #endif unsigned thread::hardware_concurrency() BOOST_NOEXCEPT { - //SYSTEM_INFO info={{0}}; SYSTEM_INFO info; -# if BOOST_PLAT_WINDOWS_RUNTIME - GetNativeSystemInfo(&info); -# else - GetSystemInfo(&info); -# endif + detail::win32::get_system_info(info); return info.dwNumberOfProcessors; } @@ -726,11 +716,7 @@ namespace boost if(handle_count) { -# if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_WINXP - unsigned long const notified_index=detail::win32::WaitForMultipleObjects(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds); -# else unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); -# endif if(notified_indexinterruption_handle,0)==0); -# else return detail::get_current_thread_data() && (detail::win32::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0); -# endif } #endif void yield() BOOST_NOEXCEPT { -#if BOOST_PLAT_WINDOWS_RUNTIME - std::this_thread::yield(); -#else - detail::win32::Sleep(0); -#endif + detail::win32::sleep(0); } #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS diff --git a/test/test_2741.cpp b/test/test_2741.cpp index 2c199139..974adacd 100644 --- a/test/test_2741.cpp +++ b/test/test_2741.cpp @@ -1,5 +1,4 @@ // Copyright (C) 2008 Vicente J. Botet Escriba -// Copyright (C) 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/test_tss.cpp b/test/test_tss.cpp index c4a35f4f..edb240e4 100644 --- a/test/test_tss.cpp +++ b/test/test_tss.cpp @@ -1,6 +1,5 @@ // Copyright (C) 2001-2003 William E. Kempf // Copyright (C) 2007 Anthony Williams -// Copyright (C) 2014 Microsoft Corporation // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)