From d34553359676874553bd3d9111aa8f260a982fb9 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Thu, 19 Oct 2017 18:14:37 +0200 Subject: [PATCH 01/10] move files from boost/detail to boost/thread/detail. --- include/boost/{ => thread}/detail/atomic_redef_macros.hpp | 0 include/boost/{ => thread}/detail/atomic_undef_macros.hpp | 0 include/boost/thread/future.hpp | 8 ++++---- 3 files changed, 4 insertions(+), 4 deletions(-) rename include/boost/{ => thread}/detail/atomic_redef_macros.hpp (100%) rename include/boost/{ => thread}/detail/atomic_undef_macros.hpp (100%) diff --git a/include/boost/detail/atomic_redef_macros.hpp b/include/boost/thread/detail/atomic_redef_macros.hpp similarity index 100% rename from include/boost/detail/atomic_redef_macros.hpp rename to include/boost/thread/detail/atomic_redef_macros.hpp diff --git a/include/boost/detail/atomic_undef_macros.hpp b/include/boost/thread/detail/atomic_undef_macros.hpp similarity index 100% rename from include/boost/detail/atomic_undef_macros.hpp rename to include/boost/thread/detail/atomic_undef_macros.hpp diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 16256230..1234cb85 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -2238,13 +2238,13 @@ namespace boost void lazy_init() { #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY -#include +#include if(!atomic_load(&future_)) { future_ptr blank; atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state)); } -#include +#include #endif } @@ -2529,13 +2529,13 @@ namespace boost void lazy_init() { #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY -#include +#include if(!atomic_load(&future_)) { future_ptr blank; atomic_compare_exchange(&future_,&blank,future_ptr(new detail::shared_state)); } -#include +#include #endif } From 44080a444cfc3626cab9ed1eb4b232b797247a33 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Tue, 24 Oct 2017 21:02:01 +0200 Subject: [PATCH 02/10] update release notes. --- doc/changes.qbk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/changes.qbk b/doc/changes.qbk index d20777e1..b986d205 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -22,14 +22,29 @@ Please take a look at [@https://svn.boost.org/trac/boost/query?status=assigned&s Please take a look at [@http://www.boost.org/development/tests/master/developer/thread.html thread master regression test] to see the last regression test snapshot. [*Fixed Bugs:] + +* [@http://svn.boost.org/trac/boost/ticket/12323 #12323] windows - boost/thread/win32/mfc_thread_init.hpp has wrong signature for _pRawDllMainOrig +* [@http://svn.boost.org/trac/boost/ticket/12730 #12730] windows - static threads library is incompatible with MSVC 2017 RC * [@http://svn.boost.org/trac/boost/ticket/12976 #12976] Boost Thread Executors documentation mistakes * [@http://svn.boost.org/trac/boost/ticket/12949 #12949] using sleep_for in a thread context without including boost/thread/thread.hpp yields incorrect behaviour when BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC is defined * [@http://svn.boost.org/trac/boost/ticket/13019 #13019] ABI compatibility for BOOST_THREAD_PROVIDES_INTERRUPTIONS incomplete +* [@http://svn.boost.org/trac/boost/ticket/13069 #13069] Boost unit test "sync_pq_multi_thread_p_lib.exe" hung in thread library * [@http://svn.boost.org/trac/boost/ticket/13163 #13163] boost::detail::heap_new does not have a variadic variant +* [@http://svn.boost.org/trac/boost/ticket/13226 #13226] getpagesize() is deprecated since 199506L + +* [@https://github.com/boostorg/thread/issues/132 #132] VS 2017.4 Preview deadlocks on Test 10964 +* [@https://github.com/boostorg/thread/issues/133 #133] windows - Spurious timing test failures on windows +* [@https://github.com/boostorg/thread/issues/134 #134] VS 2017.4 Preview deadlock in sync_pq_multi_thread_p_lib.exe +* [@https://github.com/boostorg/thread/issues/135 #135] VS 2017.4 Preview test_scheduled_tp_p.exe deadlock +* [@https://github.com/boostorg/thread/issues/136 #136] VS 2017.4 Preview test_scheduler_p.exe deadlock +* [@https://github.com/boostorg/thread/issues/137 #137] VS 2017.4 Preview executor_ex.exe deadlock +* [@https://github.com/boostorg/thread/issues/143 #143] Failures on msvc-12.0 +* [@https://github.com/boostorg/thread/issues/145 #145] Clang build error with BOOST_THREAD_ATTRIBUTE_MAY_ALIAS [*New Experimental Features:] +* [@https://github.com/boostorg/thread/issues/116 #116] [Proposal] Add APIs for deferred set_value/exception [heading Version 4.7.5 - boost 1.65.1] From 343230cd783ce59e3dd514742cfd62948d0044cc Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Wed, 25 Oct 2017 01:09:24 +0300 Subject: [PATCH 03/10] Updated Boost.WinAPI usage to the new location and namespace. --- .../thread/win32/basic_recursive_mutex.hpp | 10 +- .../boost/thread/win32/condition_variable.hpp | 6 +- include/boost/thread/win32/once.hpp | 48 +++++----- include/boost/thread/win32/shared_mutex.hpp | 30 +++--- include/boost/thread/win32/thread_data.hpp | 2 +- .../boost/thread/win32/thread_heap_alloc.hpp | 6 +- .../boost/thread/win32/thread_primitives.hpp | 92 +++++++++---------- src/win32/thread.cpp | 16 ++-- src/win32/tss_dll.cpp | 2 +- src/win32/tss_pe.cpp | 2 +- 10 files changed, 107 insertions(+), 107 deletions(-) diff --git a/include/boost/thread/win32/basic_recursive_mutex.hpp b/include/boost/thread/win32/basic_recursive_mutex.hpp index 351f9acc..f232d1fb 100644 --- a/include/boost/thread/win32/basic_recursive_mutex.hpp +++ b/include/boost/thread/win32/basic_recursive_mutex.hpp @@ -44,13 +44,13 @@ namespace boost bool try_lock() BOOST_NOEXCEPT { - long const current_thread_id=boost::detail::winapi::GetCurrentThreadId(); + long const current_thread_id=boost::winapi::GetCurrentThreadId(); return try_recursive_lock(current_thread_id) || try_basic_lock(current_thread_id); } void lock() { - long const current_thread_id=boost::detail::winapi::GetCurrentThreadId(); + long const current_thread_id=boost::winapi::GetCurrentThreadId(); if(!try_recursive_lock(current_thread_id)) { mutex.lock(); @@ -61,7 +61,7 @@ namespace boost #if defined BOOST_THREAD_USES_DATETIME bool timed_lock(::boost::system_time const& target) { - long const current_thread_id=boost::detail::winapi::GetCurrentThreadId(); + long const current_thread_id=boost::winapi::GetCurrentThreadId(); return try_recursive_lock(current_thread_id) || try_timed_lock(current_thread_id,target); } template @@ -75,13 +75,13 @@ namespace boost template bool try_lock_for(const chrono::duration& rel_time) { - long const current_thread_id=boost::detail::winapi::GetCurrentThreadId(); + long const current_thread_id=boost::winapi::GetCurrentThreadId(); return try_recursive_lock(current_thread_id) || try_timed_lock_for(current_thread_id,rel_time); } template bool try_lock_until(const chrono::time_point& t) { - long const current_thread_id=boost::detail::winapi::GetCurrentThreadId(); + long const current_thread_id=boost::winapi::GetCurrentThreadId(); return try_recursive_lock(current_thread_id) || try_timed_lock_until(current_thread_id,t); } #endif diff --git a/include/boost/thread/win32/condition_variable.hpp b/include/boost/thread/win32/condition_variable.hpp index 5ff342f1..f3f7544c 100644 --- a/include/boost/thread/win32/condition_variable.hpp +++ b/include/boost/thread/win32/condition_variable.hpp @@ -76,7 +76,7 @@ namespace boost void release(unsigned count_to_release) { notified=true; - detail::winapi::ReleaseSemaphore(semaphore,count_to_release,0); + winapi::ReleaseSemaphore(semaphore,count_to_release,0); } void release_waiters() @@ -96,7 +96,7 @@ namespace boost bool woken() { - unsigned long const woken_result=detail::winapi::WaitForSingleObjectEx(wake_sem,0,0); + unsigned long const woken_result=winapi::WaitForSingleObjectEx(wake_sem,0,0); BOOST_ASSERT((woken_result==detail::win32::timeout) || (woken_result==0)); return woken_result==0; } @@ -135,7 +135,7 @@ namespace boost void wake_waiters(long count_to_wake) { detail::interlocked_write_release(&total_count,total_count-count_to_wake); - detail::winapi::ReleaseSemaphore(wake_sem,count_to_wake,0); + winapi::ReleaseSemaphore(wake_sem,count_to_wake,0); } template diff --git a/include/boost/thread/win32/once.hpp b/include/boost/thread/win32/once.hpp index e7c565fb..56d684cc 100644 --- a/include/boost/thread/win32/once.hpp +++ b/include/boost/thread/win32/once.hpp @@ -136,9 +136,9 @@ namespace boost } #ifdef BOOST_NO_ANSI_APIS - return ::boost::detail::winapi::OpenEventW( + return ::boost::winapi::OpenEventW( #else - return ::boost::detail::winapi::OpenEventA( + return ::boost::winapi::OpenEventA( #endif ::boost::detail::win32::synchronize | ::boost::detail::win32::event_modify_state, @@ -186,7 +186,7 @@ namespace boost } if(ctx.event_handle) { - ::boost::detail::winapi::ResetEvent(ctx.event_handle); + ::boost::winapi::ResetEvent(ctx.event_handle); } return true; } @@ -207,7 +207,7 @@ namespace boost } if(ctx.event_handle) { - ::boost::detail::winapi::SetEvent(ctx.event_handle); + ::boost::winapi::SetEvent(ctx.event_handle); } } inline void rollback_once_region(once_flag& flag, once_context& ctx) BOOST_NOEXCEPT @@ -219,7 +219,7 @@ namespace boost } if(ctx.event_handle) { - ::boost::detail::winapi::SetEvent(ctx.event_handle); + ::boost::winapi::SetEvent(ctx.event_handle); } } } @@ -264,7 +264,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite, 0)); } } @@ -308,7 +308,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -355,7 +355,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -400,7 +400,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -443,7 +443,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -486,7 +486,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -529,7 +529,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -574,7 +574,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -617,7 +617,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -660,7 +660,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -703,7 +703,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -748,7 +748,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -793,7 +793,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -839,7 +839,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -886,7 +886,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -930,7 +930,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -977,7 +977,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -1024,7 +1024,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } @@ -1073,7 +1073,7 @@ namespace boost continue; } } - BOOST_VERIFY(!::boost::detail::winapi::WaitForSingleObjectEx( + BOOST_VERIFY(!::boost::winapi::WaitForSingleObjectEx( ctx.event_handle,::boost::detail::win32::infinite,0)); } } diff --git a/include/boost/thread/win32/shared_mutex.hpp b/include/boost/thread/win32/shared_mutex.hpp index d1bd9717..4482ed29 100644 --- a/include/boost/thread/win32/shared_mutex.hpp +++ b/include/boost/thread/win32/shared_mutex.hpp @@ -67,19 +67,19 @@ namespace boost { if(old_state.exclusive_waiting) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0); } if(old_state.shared_waiting || old_state.exclusive_waiting) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); } } void release_shared_waiters(state_data old_state) { if(old_state.shared_waiting || old_state.exclusive_waiting) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); } } @@ -107,9 +107,9 @@ namespace boost ~shared_mutex() { - detail::winapi::CloseHandle(upgrade_sem); - detail::winapi::CloseHandle(semaphores[unlock_sem]); - detail::winapi::CloseHandle(semaphores[exclusive_sem]); + winapi::CloseHandle(upgrade_sem); + winapi::CloseHandle(semaphores[unlock_sem]); + winapi::CloseHandle(semaphores[exclusive_sem]); } bool try_lock_shared() @@ -191,7 +191,7 @@ namespace boost return true; } - unsigned long const res=detail::winapi::WaitForSingleObjectEx(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until), 0); + unsigned long const res=winapi::WaitForSingleObjectEx(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until), 0); if(res==detail::win32::timeout) { for(;;) @@ -296,7 +296,7 @@ namespace boost unsigned long res; if (tp>n) { chrono::milliseconds rel_time= chrono::ceil(tp-n); - res=detail::winapi::WaitForSingleObjectEx(semaphores[unlock_sem], + res=winapi::WaitForSingleObjectEx(semaphores[unlock_sem], static_cast(rel_time.count()), 0); } else { res=detail::win32::timeout; @@ -375,7 +375,7 @@ namespace boost { if(old_state.upgrade) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(upgrade_sem,1,0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(upgrade_sem,1,0)!=0); } else { @@ -474,7 +474,7 @@ namespace boost #else const bool wait_all = false; #endif - unsigned long const wait_res=detail::winapi::WaitForMultipleObjectsEx(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until), 0); + unsigned long const wait_res=winapi::WaitForMultipleObjectsEx(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until), 0); if(wait_res==detail::win32::timeout) { for(;;) @@ -500,7 +500,7 @@ namespace boost state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); if (must_notify) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); } if(current_state==old_state) @@ -586,7 +586,7 @@ namespace boost unsigned long wait_res; if (tp>n) { chrono::milliseconds rel_time= chrono::ceil(tp-chrono::system_clock::now()); - wait_res=detail::winapi::WaitForMultipleObjectsEx(2,semaphores,wait_all, + wait_res=winapi::WaitForMultipleObjectsEx(2,semaphores,wait_all, static_cast(rel_time.count()), 0); } else { wait_res=detail::win32::timeout; @@ -616,7 +616,7 @@ namespace boost state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state); if (must_notify) { - BOOST_VERIFY(detail::winapi::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); + BOOST_VERIFY(winapi::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0); } if(current_state==old_state) { @@ -698,7 +698,7 @@ namespace boost return; } - BOOST_VERIFY(!detail::winapi::WaitForSingleObjectEx(semaphores[unlock_sem],detail::winapi::infinite, 0)); + BOOST_VERIFY(!winapi::WaitForSingleObjectEx(semaphores[unlock_sem],winapi::infinite, 0)); } } @@ -790,7 +790,7 @@ namespace boost { if(!last_reader) { - BOOST_VERIFY(!detail::winapi::WaitForSingleObjectEx(upgrade_sem,detail::win32::infinite, 0)); + BOOST_VERIFY(!winapi::WaitForSingleObjectEx(upgrade_sem,detail::win32::infinite, 0)); } break; } diff --git a/include/boost/thread/win32/thread_data.hpp b/include/boost/thread/win32/thread_data.hpp index ed74198f..db8678cb 100644 --- a/include/boost/thread/win32/thread_data.hpp +++ b/include/boost/thread/win32/thread_data.hpp @@ -153,7 +153,7 @@ namespace boost #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS void interrupt() { - BOOST_VERIFY(detail::winapi::SetEvent(interruption_handle)!=0); + BOOST_VERIFY(winapi::SetEvent(interruption_handle)!=0); } #endif typedef detail::win32::handle native_handle_type; diff --git a/include/boost/thread/win32/thread_heap_alloc.hpp b/include/boost/thread/win32/thread_heap_alloc.hpp index 96621355..176d269e 100644 --- a/include/boost/thread/win32/thread_heap_alloc.hpp +++ b/include/boost/thread/win32/thread_heap_alloc.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include @@ -22,7 +22,7 @@ namespace boost { inline void* allocate_raw_heap_memory(unsigned size) { - void* const heap_memory=detail::winapi::HeapAlloc(detail::winapi::GetProcessHeap(),0,size); + void* const heap_memory=winapi::HeapAlloc(winapi::GetProcessHeap(),0,size); if(!heap_memory) { boost::throw_exception(std::bad_alloc()); @@ -32,7 +32,7 @@ namespace boost inline void free_raw_heap_memory(void* heap_memory) { - BOOST_VERIFY(detail::winapi::HeapFree(detail::winapi::GetProcessHeap(),0,heap_memory)!=0); + BOOST_VERIFY(winapi::HeapFree(winapi::GetProcessHeap(),0,heap_memory)!=0); } #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) && ! defined (BOOST_NO_CXX11_RVALUE_REFERENCES) template diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index f93cc243..c9abc44f 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -16,23 +16,23 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -//#include +//#include #include #include @@ -46,20 +46,20 @@ namespace boost { namespace win32 { - typedef ::boost::detail::winapi::HANDLE_ handle; - typedef ::boost::detail::winapi::SYSTEM_INFO_ system_info; + typedef ::boost::winapi::HANDLE_ handle; + typedef ::boost::winapi::SYSTEM_INFO_ system_info; typedef unsigned __int64 ticks_type; - typedef ::boost::detail::winapi::FARPROC_ farproc_t; - unsigned const infinite=::boost::detail::winapi::INFINITE_; - unsigned const timeout=::boost::detail::winapi::WAIT_TIMEOUT_; - handle const invalid_handle_value=::boost::detail::winapi::INVALID_HANDLE_VALUE_; - unsigned const event_modify_state=::boost::detail::winapi::EVENT_MODIFY_STATE_; - unsigned const synchronize=::boost::detail::winapi::SYNCHRONIZE_; - unsigned const wait_abandoned=::boost::detail::winapi::WAIT_ABANDONED_; + typedef ::boost::winapi::FARPROC_ farproc_t; + unsigned const infinite=::boost::winapi::INFINITE_; + unsigned const timeout=::boost::winapi::WAIT_TIMEOUT_; + handle const invalid_handle_value=::boost::winapi::INVALID_HANDLE_VALUE_; + unsigned const event_modify_state=::boost::winapi::EVENT_MODIFY_STATE_; + unsigned const synchronize=::boost::winapi::SYNCHRONIZE_; + unsigned const wait_abandoned=::boost::winapi::WAIT_ABANDONED_; unsigned const create_event_initial_set = 0x00000002; unsigned const create_event_manual_reset = 0x00000001; - unsigned const event_all_access = ::boost::detail::winapi::EVENT_ALL_ACCESS_; - unsigned const semaphore_all_access = boost::detail::winapi::SEMAPHORE_ALL_ACCESS_; + unsigned const event_all_access = ::boost::winapi::EVENT_ALL_ACCESS_; + unsigned const semaphore_all_access = boost::winapi::SEMAPHORE_ALL_ACCESS_; } } } @@ -94,7 +94,7 @@ namespace boost ticks_type current_tick64; previous_count = (unsigned long) boost::detail::interlocked_read_acquire(&count); - current_tick32 = ::boost::detail::winapi::GetTickCount(); + current_tick32 = ::boost::winapi::GetTickCount(); if(previous_count == (unsigned long)-1l) { @@ -146,13 +146,13 @@ namespace boost // GetTickCount and GetModuleHandle are not allowed in the Windows Runtime, // and kernel32 isn't used in Windows Phone. #if BOOST_PLAT_WINDOWS_RUNTIME - gettickcount64impl = &::boost::detail::winapi::GetTickCount64; + gettickcount64impl = &::boost::winapi::GetTickCount64; #else farproc_t addr=GetProcAddress( #if !defined(BOOST_NO_ANSI_APIS) - ::boost::detail::winapi::GetModuleHandleA("KERNEL32.DLL"), + ::boost::winapi::GetModuleHandleA("KERNEL32.DLL"), #else - ::boost::detail::winapi::GetModuleHandleW(L"KERNEL32.DLL"), + ::boost::winapi::GetModuleHandleW(L"KERNEL32.DLL"), #endif "GetTickCount64"); if(addr) @@ -185,11 +185,11 @@ namespace boost initial_event_state state) { #if !defined(BOOST_NO_ANSI_APIS) - handle const res = ::boost::detail::winapi::CreateEventA(0, type, state, mutex_name); + handle const res = ::boost::winapi::CreateEventA(0, type, state, mutex_name); #elif BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - handle const res = ::boost::detail::winapi::CreateEventW(0, type, state, mutex_name); + handle const res = ::boost::winapi::CreateEventW(0, type, state, mutex_name); #else - handle const res = ::boost::detail::winapi::CreateEventExW( + handle const res = ::boost::winapi::CreateEventExW( 0, mutex_name, type ? create_event_manual_reset : 0 | state ? create_event_initial_set : 0, @@ -211,12 +211,12 @@ namespace boost inline handle create_anonymous_semaphore_nothrow(long initial_count,long max_count) { #if !defined(BOOST_NO_ANSI_APIS) - handle const res=::boost::detail::winapi::CreateSemaphoreA(0,initial_count,max_count,0); + handle const res=::boost::winapi::CreateSemaphoreA(0,initial_count,max_count,0); #else #if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA - handle const res=::boost::detail::winapi::CreateSemaphoreEx(0,initial_count,max_count,0,0); + handle const res=::boost::winapi::CreateSemaphoreEx(0,initial_count,max_count,0,0); #else - handle const res=::boost::detail::winapi::CreateSemaphoreExW(0,initial_count,max_count,0,0,semaphore_all_access); + handle const res=::boost::winapi::CreateSemaphoreExW(0,initial_count,max_count,0,0,semaphore_all_access); #endif #endif return res; @@ -234,10 +234,10 @@ namespace boost inline handle duplicate_handle(handle source) { - handle const current_process=::boost::detail::winapi::GetCurrentProcess(); + handle const current_process=::boost::winapi::GetCurrentProcess(); long const same_access_flag=2; handle new_handle=0; - bool const success=::boost::detail::winapi::DuplicateHandle(current_process,source,current_process,&new_handle,0,false,same_access_flag)!=0; + bool const success=::boost::winapi::DuplicateHandle(current_process,source,current_process,&new_handle,0,false,same_access_flag)!=0; if(!success) { boost::throw_exception(thread_resource_error()); @@ -247,15 +247,15 @@ namespace boost inline void release_semaphore(handle semaphore,long count) { - BOOST_VERIFY(::boost::detail::winapi::ReleaseSemaphore(semaphore,count,0)!=0); + BOOST_VERIFY(::boost::winapi::ReleaseSemaphore(semaphore,count,0)!=0); } inline void get_system_info(system_info *info) { #if BOOST_PLAT_WINDOWS_RUNTIME - ::boost::detail::winapi::GetNativeSystemInfo(info); + ::boost::winapi::GetNativeSystemInfo(info); #else - ::boost::detail::winapi::GetSystemInfo(info); + ::boost::winapi::GetSystemInfo(info); #endif } @@ -266,15 +266,15 @@ namespace boost #if BOOST_PLAT_WINDOWS_RUNTIME std::this_thread::yield(); #else - ::boost::detail::winapi::Sleep(0); + ::boost::winapi::Sleep(0); #endif } else { #if BOOST_PLAT_WINDOWS_RUNTIME - ::boost::detail::winapi::WaitForSingleObjectEx(::boost::detail::winapi::GetCurrentThread(), milliseconds, 0); + ::boost::winapi::WaitForSingleObjectEx(::boost::winapi::GetCurrentThread(), milliseconds, 0); #else - ::boost::detail::winapi::Sleep(milliseconds); + ::boost::winapi::Sleep(milliseconds); #endif } } @@ -290,7 +290,7 @@ namespace boost { if (m_completionHandle != ::boost::detail::win32::invalid_handle_value) { - ::boost::detail::winapi::CloseHandle(m_completionHandle); + ::boost::winapi::CloseHandle(m_completionHandle); } } @@ -318,7 +318,7 @@ namespace boost { if(handle_to_manage && handle_to_manage!=invalid_handle_value) { - BOOST_VERIFY(::boost::detail::winapi::CloseHandle(handle_to_manage)); + BOOST_VERIFY(::boost::winapi::CloseHandle(handle_to_manage)); } } diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 52522213..7ec81447 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -7,7 +7,7 @@ //#define BOOST_THREAD_VERSION 3 -#include +#include #include #include #include @@ -498,7 +498,7 @@ namespace boost bool thread::interruption_requested() const BOOST_NOEXCEPT { detail::thread_data_ptr local_thread_info=(get_thread_info)(); - return local_thread_info.get() && (detail::winapi::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0); + return local_thread_info.get() && (winapi::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0); } #endif @@ -726,7 +726,7 @@ namespace boost if(handle_count) { - unsigned long const notified_index=detail::winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); + unsigned long const notified_index=winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); if(notified_indexinterruption_handle); + winapi::ResetEvent(detail::get_current_thread_data()->interruption_handle); throw thread_interrupted(); } #endif @@ -810,7 +810,7 @@ namespace boost if(handle_count) { - unsigned long const notified_index=detail::winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); + unsigned long const notified_index=winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0); if(notified_indexid; } #endif - return detail::winapi::GetCurrentThreadId(); + return winapi::GetCurrentThreadId(); #else return thread::id(get_or_make_current_thread_data()); #endif @@ -858,7 +858,7 @@ namespace boost { if(interruption_enabled() && interruption_requested()) { - detail::winapi::ResetEvent(detail::get_current_thread_data()->interruption_handle); + winapi::ResetEvent(detail::get_current_thread_data()->interruption_handle); throw thread_interrupted(); } } @@ -870,7 +870,7 @@ namespace boost bool interruption_requested() BOOST_NOEXCEPT { - return detail::get_current_thread_data() && (detail::winapi::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0); + return detail::get_current_thread_data() && (winapi::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0); } #endif diff --git a/src/win32/tss_dll.cpp b/src/win32/tss_dll.cpp index cd71933c..75ea93a5 100644 --- a/src/win32/tss_dll.cpp +++ b/src/win32/tss_dll.cpp @@ -3,7 +3,7 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include diff --git a/src/win32/tss_pe.cpp b/src/win32/tss_pe.cpp index a5d258cd..e4a0a3aa 100644 --- a/src/win32/tss_pe.cpp +++ b/src/win32/tss_pe.cpp @@ -7,7 +7,7 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_LIB) From 5141adee9624b9bad27a3fdeb3d430384fd8b3f1 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 27 Oct 2017 08:06:12 +0200 Subject: [PATCH 04/10] make use of --abbreviate-paths for windows names. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 53686acd..1419f96d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -76,4 +76,4 @@ test_script: - ..\..\..\b2 config_info_travis_install %ARGS% - config_info_travis - cd ..\..\thread\test - - ..\..\..\b2 -j3 %ARGS% + - ..\..\..\b2 --abbreviate-paths -j3 %ARGS% From 609d1a7be0c96426a1d379b4faf1c6a050b3f1d4 Mon Sep 17 00:00:00 2001 From: Aleksey Katargin Date: Wed, 1 Nov 2017 11:40:50 +0300 Subject: [PATCH 05/10] allow sync policy for future then continuation (fix #111) --- include/boost/thread/future.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 1234cb85..4e50e0d3 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -4956,6 +4956,10 @@ namespace detail { return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( lock, boost::move(*this), boost::forward(func) ))); + } else if (underlying_cast(policy) & int(launch::sync)) { + return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state, future_type>( + lock, boost::move(*this), boost::forward(func) + ))); #ifdef BOOST_THREAD_PROVIDES_EXECUTORS } else if (underlying_cast(policy) & int(launch::executor)) { assert(this->future_->get_executor()); @@ -4976,6 +4980,10 @@ namespace detail { return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state, future_type>( lock, boost::move(*this), boost::forward(func) ))); + } else if (underlying_cast(policy_) & int(launch::sync)) { + return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_sync_continuation_shared_state, future_type>( + lock, boost::move(*this), boost::forward(func) + ))); #ifdef BOOST_THREAD_PROVIDES_EXECUTORS } else if (underlying_cast(policy_) & int(launch::executor)) { assert(this->future_->get_executor()); From 7ab14ac4a3f600c2ddd1e0f22c991251aa609a21 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 24 Dec 2017 03:28:43 +0300 Subject: [PATCH 06/10] future.hpp: Fixed name shadowing --- include/boost/thread/future.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 4e50e0d3..59983b8c 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -159,7 +159,7 @@ namespace boost boost::function callback; // This declaration should be only included conditionally, but is included to maintain the same layout. continuations_type continuations; - executor_ptr_type ex; + executor_ptr_type ex_; // This declaration should be only included conditionally, but is included to maintain the same layout. virtual void launch_continuation() @@ -173,18 +173,18 @@ namespace boost is_constructed(false), policy_(launch::none), continuations(), - ex() + ex_() {} - shared_state_base(exceptional_ptr const& ex_): - exception(ex_.ptr_), + shared_state_base(exceptional_ptr const& ex): + exception(ex.ptr_), done(true), is_valid_(true), is_deferred_(false), is_constructed(false), policy_(launch::none), continuations(), - ex() + ex_() {} @@ -193,23 +193,23 @@ namespace boost } executor_ptr_type get_executor() { - return ex; + return ex_; } void set_executor_policy(executor_ptr_type aex) { set_executor(); - ex = aex; + ex_ = aex; } void set_executor_policy(executor_ptr_type aex, boost::lock_guard&) { set_executor(); - ex = aex; + ex_ = aex; } void set_executor_policy(executor_ptr_type aex, boost::unique_lock&) { set_executor(); - ex = aex; + ex_ = aex; } bool valid(boost::unique_lock&) { return is_valid_; } From 2eb9f1eb86747707ea20797ef43dbb18953d74f1 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Fri, 29 Dec 2017 17:13:59 +0100 Subject: [PATCH 07/10] Inheriting std::iterator is deprecated in c++17 Therefore get rid of that and replace inheritance by lifting std::iterator's members into the derived class. Signed-off-by: Daniela Engert --- test/test_generic_locks.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/test_generic_locks.cpp b/test/test_generic_locks.cpp index 22aed6e6..0a9befcf 100644 --- a/test/test_generic_locks.cpp +++ b/test/test_generic_locks.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include BOOST_AUTO_TEST_CASE(test_lock_two_uncontended) { @@ -300,13 +302,17 @@ BOOST_AUTO_TEST_CASE(test_lock_five_in_range) } } -class dummy_iterator: - public std::iterator +class dummy_iterator { private: dummy_mutex* p; public: + typedef std::forward_iterator_tag iterator_category; + typedef dummy_mutex value_type; + typedef std::ptrdiff_t difference_type; + typedef dummy_mutex* pointer; + typedef dummy_mutex& reference; + explicit dummy_iterator(dummy_mutex* p_): p(p_) {} From 669f652f4df7e7f74b79e3c2ecd4a169d5f24d02 Mon Sep 17 00:00:00 2001 From: Brian Kuhl Date: Fri, 12 Jan 2018 01:08:11 -0500 Subject: [PATCH 08/10] Add CPU count for VxWorks --- src/pthread/thread.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index 5e51f8ea..3cac2385 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -27,6 +27,10 @@ #include #endif +#if defined(__VXWORKS__) +#include +#endif + #include #include #include @@ -556,6 +560,18 @@ namespace boost #elif defined(BOOST_HAS_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) int const count=sysconf(_SC_NPROCESSORS_ONLN); return (count>0)?count:0; +#elif defined(__VXWORKS__) + cpuset_t set = ::vxCpuEnabledGet(); + #ifdef __DCC__ + int i; + for( i = 0; set; ++i) + { + set &= set -1; + } + return(i); + #else + return (__builtin_popcount(set) ); + #endif #elif defined(__GLIBC__) return get_nprocs(); #else From 072bbee63e19ec11ac2c279b779fe7f515c48db2 Mon Sep 17 00:00:00 2001 From: Shinobu Kinjo Date: Mon, 22 Jan 2018 09:41:48 +0900 Subject: [PATCH 09/10] future.hpp: 1) Removed redundant access specifiers and unused variables in future_deferred_shared_state 2) check lock before unlock --- include/boost/thread/future.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 59983b8c..b1d5b34b 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -1007,10 +1007,8 @@ namespace boost template struct future_deferred_shared_state: shared_state { - typedef shared_state base_type; Fp func_; - public: explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) : func_(boost::move(f)) { @@ -1035,10 +1033,8 @@ namespace boost template struct future_deferred_shared_state: shared_state { - typedef shared_state base_type; Fp func_; - public: explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) : func_(boost::move(f)) { @@ -1060,10 +1056,8 @@ namespace boost template struct future_deferred_shared_state: shared_state { - typedef shared_state base_type; Fp func_; - public: explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) : func_(boost::move(f)) { @@ -1091,7 +1085,6 @@ namespace boost public: typedef std::vector::size_type count_type; private: - struct registered_waiter; struct registered_waiter { boost::shared_ptr future_; From 99c2dd9cbcf1afcd839a32cfddf3dffe2abba24d Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 28 Jan 2018 11:33:19 +0100 Subject: [PATCH 10/10] fix : terminating with uncaught exception of type boost::unit_test::framework::setup_error. --- test/test_lock_concept.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_lock_concept.cpp b/test/test_lock_concept.cpp index 78e70120..ba7de5cd 100644 --- a/test/test_lock_concept.cpp +++ b/test/test_lock_concept.cpp @@ -440,8 +440,8 @@ void test_lock_is_scoped_lock_concept_for_mutex() test_unlocked_after_try_lock_if_other_thread_has_lock()(); } -typedef boost::mpl::vector mutex_types_with_scoped_lock; +typedef boost::mpl::vector mutex_types_with_scoped_lock; BOOST_AUTO_TEST_CASE_TEMPLATE(test_scoped_lock_concept,Mutex,mutex_types_with_scoped_lock) { @@ -450,8 +450,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_scoped_lock_concept,Mutex,mutex_types_with_sc test_lock_is_scoped_lock_concept_for_mutex(); } -typedef boost::mpl::vector all_mutex_types; +typedef boost::mpl::vector all_mutex_types; BOOST_AUTO_TEST_CASE_TEMPLATE(test_unique_lock_is_scoped_lock,Mutex,all_mutex_types) {