From 7cb5211e256a72116ec2c7c677ef084f6eb2196f Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 29 May 2015 20:02:08 +0200 Subject: [PATCH 01/14] fix typo on poly lockables. --- include/boost/thread/poly_lockable.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/thread/poly_lockable.hpp b/include/boost/thread/poly_lockable.hpp index 73461881..fffcbce1 100644 --- a/include/boost/thread/poly_lockable.hpp +++ b/include/boost/thread/poly_lockable.hpp @@ -31,7 +31,7 @@ namespace boost //] //[poly_lockable - class poly_lockable : public basic_poly_lockable + class poly_lockable : public basic_poly_lockable { public: @@ -41,7 +41,7 @@ namespace boost //] //[timed_poly_lockable - class timed_poly_lockable: public poly_lockable + class timed_poly_lockable: public poly_lockable { public: virtual ~timed_poly_lockable()=0; From b980b884744b816a418c09f0f98ad9758c9d7dcb Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Fri, 5 Jun 2015 17:48:53 +0200 Subject: [PATCH 02/14] Fix typo There was a typo in the code with both BOOST_USE_WINDOWS_H and BOOST_NO_ANSI_APIS defined. --- include/boost/thread/win32/thread_primitives.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index d0d4f0ae..42d5965a 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -59,7 +59,7 @@ namespace boost using ::CreateSemaphoreExW; # endif using ::OpenEventW; - using ::GetModuleGandleW; + using ::GetModuleHandleW; # else using ::CreateMutexA; using ::CreateEventA; From 55c21919fcbef453540be8c7e20a7f70ac2d41a2 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 21 Jun 2015 17:37:30 +0200 Subject: [PATCH 03/14] try to remove some warnings. --- example/tennis.cpp | 2 +- .../concurrent_queues/sync_timed_queue.hpp | 2 +- .../thread/executors/basic_thread_pool.hpp | 2 +- .../boost/thread/executors/loop_executor.hpp | 2 +- .../thread/executors/serial_executor.hpp | 2 +- .../experimental/parallel/v2/task_region.hpp | 2 +- include/boost/thread/future.hpp | 24 +++++++++---------- .../set_value_at_thread_exit_void_pass.cpp | 2 +- .../sync_pq/pq_multi_thread_pass.cpp | 4 ++-- test/test_2741.cpp | 2 ++ test/test_4648.cpp | 2 +- test/test_4882.cpp | 2 +- 12 files changed, 25 insertions(+), 23 deletions(-) diff --git a/example/tennis.cpp b/example/tennis.cpp index 0212f677..61d49b27 100644 --- a/example/tennis.cpp +++ b/example/tennis.cpp @@ -39,7 +39,7 @@ const char* player_name(int state) if (state == PLAYER_B) return "PLAYER-B"; throw "bad player"; - return 0; + //return 0; } void player(int active) diff --git a/include/boost/thread/concurrent_queues/sync_timed_queue.hpp b/include/boost/thread/concurrent_queues/sync_timed_queue.hpp index 8f24f43e..36223d87 100644 --- a/include/boost/thread/concurrent_queues/sync_timed_queue.hpp +++ b/include/boost/thread/concurrent_queues/sync_timed_queue.hpp @@ -235,7 +235,7 @@ namespace detail if (super::closed(lk)) return true; super::not_empty_.wait(lk); } - return false; + //return false; } /////////////////////////// diff --git a/include/boost/thread/executors/basic_thread_pool.hpp b/include/boost/thread/executors/basic_thread_pool.hpp index 001a628f..69b7b538 100644 --- a/include/boost/thread/executors/basic_thread_pool.hpp +++ b/include/boost/thread/executors/basic_thread_pool.hpp @@ -60,7 +60,7 @@ namespace executors catch (...) { std::terminate(); - return false; + //return false; } } /** diff --git a/include/boost/thread/executors/loop_executor.hpp b/include/boost/thread/executors/loop_executor.hpp index e9eadadf..03412030 100644 --- a/include/boost/thread/executors/loop_executor.hpp +++ b/include/boost/thread/executors/loop_executor.hpp @@ -54,7 +54,7 @@ namespace executors catch (...) { std::terminate(); - return false; + //return false; } } private: diff --git a/include/boost/thread/executors/serial_executor.hpp b/include/boost/thread/executors/serial_executor.hpp index 6f426666..fe4e327f 100644 --- a/include/boost/thread/executors/serial_executor.hpp +++ b/include/boost/thread/executors/serial_executor.hpp @@ -82,7 +82,7 @@ namespace executors catch (...) { std::terminate(); - return false; + //return false; } } private: diff --git a/include/boost/thread/experimental/parallel/v2/task_region.hpp b/include/boost/thread/experimental/parallel/v2/task_region.hpp index 3a278c50..e4a58331 100755 --- a/include/boost/thread/experimental/parallel/v2/task_region.hpp +++ b/include/boost/thread/experimental/parallel/v2/task_region.hpp @@ -53,7 +53,7 @@ BOOST_THREAD_INLINE_NAMESPACE(v2) throw; } #if defined BOOST_THREAD_TASK_REGION_HAS_SHARED_CANCELED - catch (task_canceled_exception& ex) + catch (task_canceled_exception&) { } #endif diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index e2dcb434..67490d9a 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -3548,8 +3548,8 @@ namespace detail )); } else { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); } } @@ -3572,12 +3572,12 @@ namespace detail return ::boost::move(ret); } else if (underlying_cast(policy) & int(launch::deferred)) { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); } else { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); } } #endif @@ -3612,8 +3612,8 @@ namespace detail )); } else { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); } } @@ -3637,8 +3637,8 @@ namespace detail return ::boost::move(ret); } else if (underlying_cast(policy) & int(launch::deferred)) { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); // return boost::detail::make_future_deferred_shared_state( // BF( // thread_detail::decay_copy(boost::forward(f)) @@ -3646,8 +3646,8 @@ namespace detail // ); } else { std::terminate(); - BOOST_THREAD_FUTURE ret; - return ::boost::move(ret); + //BOOST_THREAD_FUTURE ret; + //return ::boost::move(ret); } } #endif // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) diff --git a/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp b/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp index 81d5afeb..c79f2a23 100644 --- a/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp +++ b/test/sync/futures/promise/set_value_at_thread_exit_void_pass.cpp @@ -54,7 +54,7 @@ int main() BOOST_TEST(i == 1); } - catch(std::exception& ex) + catch(std::exception& ) { BOOST_TEST(false); } diff --git a/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp b/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp index d8e82c2e..d0626b98 100644 --- a/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp +++ b/test/sync/mutual_exclusion/sync_pq/pq_multi_thread_pass.cpp @@ -105,7 +105,7 @@ void atomic_pull(sync_pq* q, boost::atomic* sum) const int val = q->pull(); sum->fetch_add(val); } - catch(std::exception& e ){ + catch(std::exception& ){ break; } } @@ -147,7 +147,7 @@ void move_between_queues(sync_pq* q1, sync_pq* q2) const int val = q1->pull(); q2->push(val); } - catch(std::exception& e){ + catch(std::exception& ){ break; } } diff --git a/test/test_2741.cpp b/test/test_2741.cpp index 793e68cd..15826220 100644 --- a/test/test_2741.cpp +++ b/test/test_2741.cpp @@ -35,6 +35,7 @@ BOOST_AUTO_TEST_CASE(test_native_handle) boost::thread_attributes attrs; boost::thread_attributes::native_handle_type* h = attrs.native_handle(); + (void)(h); // unused #if defined(BOOST_THREAD_PLATFORM_WIN32) // ... window version #elif defined(BOOST_THREAD_PLATFORM_PTHREAD) @@ -75,3 +76,4 @@ BOOST_AUTO_TEST_CASE(test_creation_with_attrs) timed_test(&do_test_creation_with_attrs, 1); } + diff --git a/test/test_4648.cpp b/test/test_4648.cpp index 6a929b5f..34fb131a 100644 --- a/test/test_4648.cpp +++ b/test/test_4648.cpp @@ -30,7 +30,7 @@ int boostThreadLocksTest::firstFunction(boostThreadLocksTest *pBoostThreadLocksT std::cout<<"Returning from "<& upgr) { +int boostThreadLocksTest::secondFunction(boostThreadLocksTest *, boost::upgrade_lock& upgr) { std::cout<<"Before Exclusive Locking "< localUniqueLock(upgr); std::cout<<"After Exclusive Locking "<" << BOOST_THREAD_END_LOG; } From 6e002ae3ec0938cd13b389dbf64af1bbcb8f4f53 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 21 Jun 2015 23:09:15 +0200 Subject: [PATCH 04/14] try to remove more warnings. --- example/tss.cpp | 1 + .../mutual_exclusion/deque_views/single_thread_pass.cpp | 2 +- .../mutual_exclusion/queue_views/single_thread_pass.cpp | 2 +- test/test_10964.cpp | 1 + test/threads/this_thread/sleep_until/sleep_until_pass.cpp | 8 ++++---- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/example/tss.cpp b/example/tss.cpp index 0b8a2b32..f5f108e1 100644 --- a/example/tss.cpp +++ b/example/tss.cpp @@ -24,6 +24,7 @@ void thread_proc() increment(); int* p = value.get(); assert(*p == i+1); + (void)(p); } } diff --git a/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp b/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp index ec310192..ba9c75b9 100644 --- a/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp +++ b/test/sync/mutual_exclusion/deque_views/single_thread_pass.cpp @@ -185,7 +185,7 @@ int main() // empty queue try_push lvalue succeeds boost::deque_adaptor > sq; boost::deque_back q(sq); - int i; + int i=0; BOOST_TEST(boost::queue_op_status::success == q.try_push(i)); BOOST_TEST(! q.empty()); BOOST_TEST(! q.full()); diff --git a/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp b/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp index d40c1157..b55f55c7 100644 --- a/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp +++ b/test/sync/mutual_exclusion/queue_views/single_thread_pass.cpp @@ -185,7 +185,7 @@ int main() // empty queue try_push lvalue succeeds boost::queue_adaptor > sq; boost::queue_back q(sq); - int i; + int i=0; BOOST_TEST(boost::queue_op_status::success == q.try_push(i)); BOOST_TEST(! q.empty()); BOOST_TEST(! q.full()); diff --git a/test/test_10964.cpp b/test/test_10964.cpp index 6cd26759..2ab620e4 100644 --- a/test/test_10964.cpp +++ b/test/test_10964.cpp @@ -49,6 +49,7 @@ void p1() int main() { const int number_of_tests = 2; + (void)(number_of_tests); #if ! defined BOOST_NO_CXX11_DECLTYPE && ! defined BOOST_NO_CXX11_AUTO_DECLARATIONS std::cout << __FILE__ << "[" << __LINE__ << "]" << std::endl; diff --git a/test/threads/this_thread/sleep_until/sleep_until_pass.cpp b/test/threads/this_thread/sleep_until/sleep_until_pass.cpp index 8f003d84..232712ee 100644 --- a/test/threads/this_thread/sleep_until/sleep_until_pass.cpp +++ b/test/threads/this_thread/sleep_until/sleep_until_pass.cpp @@ -28,7 +28,7 @@ int main() { typedef boost::chrono::steady_clock Clock; typedef Clock::time_point time_point; - typedef Clock::duration duration; + //typedef Clock::duration duration; boost::chrono::milliseconds ms(500); time_point t0 = Clock::now(); boost::this_thread::sleep_until(t0 + ms); @@ -43,7 +43,7 @@ int main() { typedef boost::chrono::system_clock Clock; typedef Clock::time_point time_point; - typedef Clock::duration duration; + //typedef Clock::duration duration; boost::chrono::milliseconds ms(500); time_point t0 = Clock::now(); boost::this_thread::sleep_until(t0 + ms); @@ -58,7 +58,7 @@ int main() { typedef boost::chrono::steady_clock Clock; typedef Clock::time_point time_point; - typedef Clock::duration duration; + //typedef Clock::duration duration; boost::chrono::milliseconds ms(500); time_point t0 = Clock::now(); boost::this_thread::no_interruption_point::sleep_until(t0 + ms); @@ -73,7 +73,7 @@ int main() { typedef boost::chrono::system_clock Clock; typedef Clock::time_point time_point; - typedef Clock::duration duration; + //typedef Clock::duration duration; boost::chrono::milliseconds ms(500); time_point t0 = Clock::now(); boost::this_thread::no_interruption_point::sleep_until(t0 + ms); From 8c974800f90dc5f644895f2d7247364710edcf76 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Tue, 23 Jun 2015 19:05:32 +0200 Subject: [PATCH 05/14] try to remove yet more warnings. --- example/executor.cpp | 2 +- example/future_when_all.cpp | 3 ++ include/boost/thread/future.hpp | 16 ++++---- .../boost/thread/win32/thread_primitives.hpp | 40 +++++++++---------- .../make_unique_lock_try_to_lock_pass.cpp | 2 +- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/example/executor.cpp b/example/executor.cpp index 69de41f0..3c45037e 100644 --- a/example/executor.cpp +++ b/example/executor.cpp @@ -154,7 +154,7 @@ int main() { return test_executor_adaptor(); -#if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \ +#if 0 && defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION \ && defined BOOST_THREAD_PROVIDES_EXECUTORS \ && ! defined BOOST_NO_CXX11_RVALUE_REFERENCES diff --git a/example/future_when_all.cpp b/example/future_when_all.cpp index b467acb0..48f3e153 100644 --- a/example/future_when_all.cpp +++ b/example/future_when_all.cpp @@ -58,6 +58,8 @@ int p2(boost::future f) } BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG; + return 0; + } int p2s(boost::shared_future f) { @@ -81,6 +83,7 @@ int p2s(boost::shared_future f) } BOOST_THREAD_LOG << "P2>" << BOOST_THREAD_END_LOG; + return 0; } int main() diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 67490d9a..be2a6e6b 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -958,9 +958,10 @@ namespace boost class future_waiter { - struct registered_waiter; + public: typedef std::vector::size_type count_type; - + private: + struct registered_waiter; struct registered_waiter { boost::shared_ptr future_; @@ -1099,7 +1100,7 @@ namespace boost #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES template - typename boost::enable_if,unsigned>::type wait_for_any(F1& f1,F2& f2) + typename boost::enable_if,typename detail::future_waiter::count_type>::type wait_for_any(F1& f1,F2& f2) { detail::future_waiter waiter; waiter.add(f1); @@ -1108,7 +1109,7 @@ namespace boost } template - unsigned wait_for_any(F1& f1,F2& f2,F3& f3) + typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3) { detail::future_waiter waiter; waiter.add(f1); @@ -1118,7 +1119,7 @@ namespace boost } template - unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4) + typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4) { detail::future_waiter waiter; waiter.add(f1); @@ -1129,7 +1130,7 @@ namespace boost } template - unsigned wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5) + typename detail::future_waiter::count_type wait_for_any(F1& f1,F2& f2,F3& f3,F4& f4,F5& f5) { detail::future_waiter waiter; waiter.add(f1); @@ -1141,7 +1142,8 @@ namespace boost } #else template - typename boost::enable_if, unsigned>::type wait_for_any(F1& f1, Fs&... fs) + typename boost::enable_if, typename detail::future_waiter::count_type>::type + wait_for_any(F1& f1, Fs&... fs) { detail::future_waiter waiter; waiter.add(f1, fs...); diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index 42d5965a..2d7a70ed 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -46,7 +46,7 @@ namespace boost unsigned const create_event_manual_reset = 0x00000001; unsigned const event_all_access = EVENT_ALL_ACCESS; unsigned const semaphore_all_access = SEMAPHORE_ALL_ACCESS; - + # ifdef BOOST_NO_ANSI_APIS # if BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA @@ -79,8 +79,8 @@ namespace boost using ::ReleaseSemaphore; using ::SetEvent; using ::ResetEvent; - using ::WaitForMultipleObjectsEx; - using ::WaitForSingleObjectEx; + using ::WaitForMultipleObjectsEx; + using ::WaitForSingleObjectEx; using ::GetCurrentProcessId; using ::GetCurrentThreadId; using ::GetCurrentThread; @@ -91,7 +91,7 @@ namespace boost using ::Sleep; using ::QueueUserAPC; using ::GetProcAddress; -#endif +#endif } } } @@ -286,7 +286,7 @@ namespace boost } // Oops, we weren't called often enough, we're stuck - return 0xFFFFFFFF; + return 0xFFFFFFFF; } #else #endif @@ -295,12 +295,12 @@ namespace boost static detail::gettickcount64_t gettickcount64impl; if(gettickcount64impl) return gettickcount64impl; - + // GetTickCount and GetModuleHandle are not allowed in the Windows Runtime, // and kernel32 isn't used in Windows Phone. #if BOOST_PLAT_WINDOWS_RUNTIME gettickcount64impl = &GetTickCount64; -#else +#else farproc_t addr=GetProcAddress( #if !defined(BOOST_NO_ANSI_APIS) GetModuleHandleA("KERNEL32.DLL"), @@ -312,7 +312,7 @@ namespace boost gettickcount64impl=(detail::gettickcount64_t) addr; else gettickcount64impl=&GetTickCount64emulation; -#endif +#endif return gettickcount64impl; } @@ -343,14 +343,14 @@ namespace boost handle const res = win32::CreateEventW(0, type, state, mutex_name); #else handle const res = win32::CreateEventExW( - 0, - mutex_name, + 0, + mutex_name, type ? create_event_manual_reset : 0 | state ? create_event_initial_set : 0, 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); @@ -374,7 +374,7 @@ namespace boost #endif return res; } - + inline handle create_anonymous_semaphore(long initial_count,long max_count) { handle const res=create_anonymous_semaphore_nothrow(initial_count,max_count); @@ -402,20 +402,20 @@ namespace boost { BOOST_VERIFY(ReleaseSemaphore(semaphore,count,0)!=0); } - + inline void get_system_info(system_info *info) { #if BOOST_PLAT_WINDOWS_RUNTIME - win32::GetNativeSystemInfo(info); + win32::GetNativeSystemInfo(info); #else win32::GetSystemInfo(info); #endif } - + inline void sleep(unsigned long milliseconds) { if(milliseconds == 0) - { + { #if BOOST_PLAT_WINDOWS_RUNTIME std::this_thread::yield(); #else @@ -425,13 +425,13 @@ namespace boost else { #if BOOST_PLAT_WINDOWS_RUNTIME - ::boost::detail::win32::WaitForSingleObjectEx(::boost::detail::win32::GetCurrentThread(), milliseconds, 0); + ::boost::detail::win32::WaitForSingleObjectEx(::boost::detail::win32::GetCurrentThread(), milliseconds, 0); #else ::boost::detail::win32::Sleep(milliseconds); #endif } } - + #if BOOST_PLAT_WINDOWS_RUNTIME class BOOST_THREAD_DECL scoped_winrt_thread { @@ -639,7 +639,7 @@ namespace boost } old=current; } - while(true); + for(;;); return (old&value)!=0; } @@ -656,7 +656,7 @@ namespace boost } old=current; } - while(true); + for(;;); return (old&value)!=0; } } diff --git a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp index bd7cff13..66f64339 100644 --- a/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp +++ b/test/sync/mutual_exclusion/locks/unique_lock/cons/make_unique_lock_try_to_lock_pass.cpp @@ -74,7 +74,7 @@ void f() } { time_point t0 = Clock::now(); - while (true) + for (;;) { #if ! defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) auto From ccd1cd5808476d6ea3d09d5acc9e327372cb3143 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 28 Jun 2015 11:27:02 +0200 Subject: [PATCH 06/14] fix Link to archived copy of article. --- doc/sync_tutorial.qbk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/sync_tutorial.qbk b/doc/sync_tutorial.qbk index dd4002c7..0765dcb1 100644 --- a/doc/sync_tutorial.qbk +++ b/doc/sync_tutorial.qbk @@ -7,8 +7,10 @@ [section:tutorial Tutorial] + [@http://web.archive.org/web/20140531071228/http://home.roadrunner.com/~hinnant/mutexes/locking.html Handling mutexes in C++] is an excellent tutorial. You need just replace std and ting by boost. + [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2406.html Mutex, Lock, Condition Variable Rationale] adds rationale for the design decisions made for mutexes, locks and condition variables. From 44272d3b7c13902b1916fdac2bc1b644002d75d3 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Mon, 29 Jun 2015 08:43:01 +0200 Subject: [PATCH 07/14] fix for(;;); . --- include/boost/thread/win32/thread_primitives.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index 2d7a70ed..844deff9 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -639,7 +639,7 @@ namespace boost } old=current; } - for(;;); + for(;;) {} return (old&value)!=0; } @@ -656,7 +656,7 @@ namespace boost } old=current; } - for(;;); + for(;;) {} return (old&value)!=0; } } From 4f9a08c4185ff7cddb4d9555b03b24ad4ab990ae Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Wed, 1 Jul 2015 13:21:39 +0200 Subject: [PATCH 08/14] fix for(;;){} . --- include/boost/thread/win32/thread_primitives.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/thread/win32/thread_primitives.hpp b/include/boost/thread/win32/thread_primitives.hpp index 844deff9..b63503ad 100644 --- a/include/boost/thread/win32/thread_primitives.hpp +++ b/include/boost/thread/win32/thread_primitives.hpp @@ -639,7 +639,7 @@ namespace boost } old=current; } - for(;;) {} + while(true) ; return (old&value)!=0; } @@ -656,7 +656,7 @@ namespace boost } old=current; } - for(;;) {} + while(true) ; return (old&value)!=0; } } From b8dbe960b7e7777cadeac2e12be80058f77675ec Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 18 Aug 2015 18:20:25 +0100 Subject: [PATCH 09/14] Fix to get Thread lib building with Oracle C++ See https://svn.boost.org/trac/boost/ticket/11550 --- include/boost/thread/pthread/once_atomic.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/thread/pthread/once_atomic.hpp b/include/boost/thread/pthread/once_atomic.hpp index 923f07bd..5eb9baf3 100644 --- a/include/boost/thread/pthread/once_atomic.hpp +++ b/include/boost/thread/pthread/once_atomic.hpp @@ -233,7 +233,7 @@ namespace boost thread_detail::commit_once_region(flag); } } - +#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) template inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) { @@ -302,7 +302,7 @@ namespace boost } } - +#endif // __SUNPRO_CC #endif } From ff375e278066dbd55f0e535a5f495a2e72e641f5 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Thu, 20 Aug 2015 10:51:23 +0100 Subject: [PATCH 10/14] Move Oracle workaround to correct location --- include/boost/thread/pthread/once_atomic.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/thread/pthread/once_atomic.hpp b/include/boost/thread/pthread/once_atomic.hpp index 5eb9baf3..c54a35c5 100644 --- a/include/boost/thread/pthread/once_atomic.hpp +++ b/include/boost/thread/pthread/once_atomic.hpp @@ -214,7 +214,7 @@ namespace boost thread_detail::commit_once_region(flag); } } - +#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) template inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f) { @@ -233,7 +233,7 @@ namespace boost thread_detail::commit_once_region(flag); } } -#if !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130)) + template inline void call_once(once_flag& flag, BOOST_THREAD_RV_REF(Function) f, BOOST_THREAD_RV_REF(T1) p1) { From ac603f6bd1d60daab741001037db3017a3a92f67 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 21 Aug 2015 18:35:36 +0200 Subject: [PATCH 11/14] fix devector allocator_traits_type specific usage. --- include/boost/thread/csbl/devector.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/boost/thread/csbl/devector.hpp b/include/boost/thread/csbl/devector.hpp index c11ad29b..c2bc0bbe 100644 --- a/include/boost/thread/csbl/devector.hpp +++ b/include/boost/thread/csbl/devector.hpp @@ -21,8 +21,8 @@ namespace boost template class devector { - typedef vector vector_type; - vector data_; + typedef csbl::vector vector_type; + vector_type data_; std::size_t front_index_; BOOST_COPYABLE_AND_MOVABLE(devector) @@ -58,7 +58,9 @@ namespace boost } devector& operator=(BOOST_RV_REF(devector) x) - BOOST_NOEXCEPT_IF(vector::allocator_traits_type::propagate_on_container_move_assignment::value) +#if defined BOOST_THREAD_USES_BOOST_VECTOR + BOOST_NOEXCEPT_IF(vector_type::allocator_traits_type::propagate_on_container_move_assignment::value) +#endif { data_ = boost::move(x.data_); front_index_ = x.front_index_; From 0143748de80617b25557eae47fd74e92af8f623b Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 21 Aug 2015 18:37:08 +0200 Subject: [PATCH 12/14] Add test_11499. --- test/Jamfile.v2 | 1 + test/test_11499.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 test/test_11499.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 88ab9cb7..62867cac 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -959,6 +959,7 @@ rule thread-compile ( sources : reqs * : name ) test-suite ts_ : #[ thread-run test_11256.cpp ] + [ thread-run test_11499.cpp ] ; diff --git a/test/test_11499.cpp b/test/test_11499.cpp new file mode 100644 index 00000000..2fe07ae8 --- /dev/null +++ b/test/test_11499.cpp @@ -0,0 +1,56 @@ +// Copyright (C) 2014 Vicente Botet +// +// 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) + +#define BOOST_THREAD_VERSION 4 + +#include +#include +#include +#include +#include +#include + +using MutexT = boost::shared_mutex; +using ReaderLockT = std::lock_guard; +using WriterLockT = std::shared_lock; + +MutexT gMutex; +std::atomic running(true); + + +void myread() +{ + long reads = 0; + while (running && reads < 100000) + { + ReaderLockT lock(gMutex); + std::this_thread::yield(); + ++reads; + } +} + +int main() +{ + using namespace std; + + vector threads; + for (int i = 0; i < 256; ++i) + { + threads.emplace_back(thread(myread)); + } + +// string str; +// +// getline(std::cin, str); + running = false; + + for (auto& thread : threads) + { + thread.join(); + } + + return 0; +} + From 1ae07f3f3afcc63a05b8a14c57e360464ccd8e29 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 21 Aug 2015 18:37:42 +0200 Subject: [PATCH 13/14] Add shared_timed_mutex typedef. --- include/boost/thread/shared_mutex.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/thread/shared_mutex.hpp b/include/boost/thread/shared_mutex.hpp index b968f2ac..ce5d6d1b 100644 --- a/include/boost/thread/shared_mutex.hpp +++ b/include/boost/thread/shared_mutex.hpp @@ -28,6 +28,7 @@ namespace boost { + typedef shared_mutex shared_timed_mutex; namespace sync { #ifdef BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES From b332f17825b4abb48d190bb24dff0873fe936b34 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Wed, 2 Sep 2015 22:39:26 +0200 Subject: [PATCH 14/14] Added failing test for #11611. --- test/Jamfile.v2 | 3 ++- test/test_11611.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 test/test_11611.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 62867cac..9d8221bb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -959,7 +959,8 @@ rule thread-compile ( sources : reqs * : name ) test-suite ts_ : #[ thread-run test_11256.cpp ] - [ thread-run test_11499.cpp ] + #[ thread-run test_11499.cpp ] + [ thread-run test_11611.cpp ] ; diff --git a/test/test_11611.cpp b/test/test_11611.cpp new file mode 100644 index 00000000..9a0ffd41 --- /dev/null +++ b/test/test_11611.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2014 Vicente Botet +// +// 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) + +//#define BOOST_THREAD_VERSION 4 + +#include +//#include + +#define BOOST_THREAD_PROVIDES_FUTURE +#define BOOST_THREAD_PROVIDES_EXECUTORS +#define BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION +#include +#include +#include + +using namespace std; + +int main() +{ + boost::loop_executor ex; + + //thread t([&ex]() + boost::thread t([&ex]() + { + ex.loop(); + }); + + { + boost::serial_executor_cont serial(ex); + + for (size_t i = 0; i < 100000; i++) + serial.submit([i] { + //std::cout << i << "."; + }); + + serial.close(); + } + + ex.close(); + + t.join(); + std::cout << "end" << std::endl; + return 0; +}