From 4d62627668a9641db96f40d0e60b0452cc17a52c Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Fri, 13 Apr 2018 20:06:03 +0200 Subject: [PATCH] Make it possible to compile with BOOST_NO_EXCEPTIONS defined --- include/boost/thread/detail/thread.hpp | 2 ++ include/boost/thread/future.hpp | 11 ++++++++++- include/boost/thread/pthread/thread_data.hpp | 12 ++++++++---- include/boost/thread/win32/thread_data.hpp | 11 ++++++++--- src/future.cpp | 9 ++++++++- src/pthread/thread.cpp | 16 +++++++++++----- src/win32/thread.cpp | 4 ++++ 7 files changed, 51 insertions(+), 14 deletions(-) diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 52af1ba2..46d96693 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -811,6 +811,7 @@ namespace boost }; void BOOST_THREAD_DECL add_thread_exit_function(thread_exit_function_base*); +//#ifndef BOOST_NO_EXCEPTIONS struct shared_state_base; #if defined(BOOST_THREAD_PLATFORM_WIN32) inline void make_ready_at_thread_exit(shared_ptr as) @@ -824,6 +825,7 @@ namespace boost #else void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr as); #endif +//#endif } namespace this_thread diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index e5fd1921..f4b3fb96 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -15,7 +15,16 @@ //#define BOOST_THREAD_CONTINUATION_SYNC -#ifndef BOOST_NO_EXCEPTIONS +#ifdef BOOST_NO_EXCEPTIONS +namespace boost +{ + +struct shared_state_base { + void notify_deferred(); +}; + +} +#else #include #include diff --git a/include/boost/thread/pthread/thread_data.hpp b/include/boost/thread/pthread/thread_data.hpp index 859ccfbd..ea8da65e 100644 --- a/include/boost/thread/pthread/thread_data.hpp +++ b/include/boost/thread/pthread/thread_data.hpp @@ -130,9 +130,10 @@ namespace boost > notify_list_t; notify_list_t notify; +//#ifndef BOOST_NO_EXCEPTIONS typedef std::vector > async_states_t; async_states_t async_states_; - +//#endif //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS // These data must be at the end so that the access to the other fields doesn't change // when BOOST_THREAD_PROVIDES_INTERRUPTIONS is defined. @@ -148,8 +149,10 @@ namespace boost cond_mutex(0), current_cond(0), //#endif - notify(), - async_states_() + notify() +//#ifndef BOOST_NO_EXCEPTIONS + , async_states_() +//#endif //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS , interrupt_enabled(true) , interrupt_requested(false) @@ -165,11 +168,12 @@ namespace boost notify.push_back(std::pair(cv, m)); } +//#ifndef BOOST_NO_EXCEPTIONS void make_ready_at_thread_exit(shared_ptr as) { async_states_.push_back(as); } - +//#endif }; BOOST_THREAD_DECL thread_data_base* get_current_thread_data(); diff --git a/include/boost/thread/win32/thread_data.hpp b/include/boost/thread/win32/thread_data.hpp index f87889ef..2f288202 100644 --- a/include/boost/thread/win32/thread_data.hpp +++ b/include/boost/thread/win32/thread_data.hpp @@ -113,8 +113,10 @@ namespace boost > notify_list_t; notify_list_t notify; +//#ifndef BOOST_NO_EXCEPTIONS typedef std::vector > async_states_t; async_states_t async_states_; +//#endif //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS // These data must be at the end so that the access to the other fields doesn't change // when BOOST_THREAD_PROVIDES_INTERRUPTIONS is defined @@ -129,8 +131,10 @@ namespace boost thread_exit_callbacks(0), id(0), tss_data(), - notify(), - async_states_() + notify() +//#ifndef BOOST_NO_EXCEPTIONS + , async_states_() +//#endif //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS , interruption_handle(create_anonymous_event(detail::win32::manual_reset_event,detail::win32::event_initially_reset)) , interruption_enabled(true) @@ -166,11 +170,12 @@ namespace boost notify.push_back(std::pair(cv, m)); } +//#ifndef BOOST_NO_EXCEPTIONS void make_ready_at_thread_exit(shared_ptr as) { async_states_.push_back(as); } - +//#endif }; BOOST_THREAD_DECL thread_data_base* get_current_thread_data(); diff --git a/src/future.cpp b/src/future.cpp index 4aeac94a..35b8853f 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -4,7 +4,14 @@ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include -#ifndef BOOST_NO_EXCEPTIONS + +#ifdef BOOST_NO_EXCEPTIONS +namespace boost +{ + void shared_state_base::notify_deferred() {} +} + +#else #include diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index 1be5bae2..bb3d9a17 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -27,9 +27,9 @@ #include #endif -#if defined(__VXWORKS__) +#if defined(__VXWORKS__) #include -#endif +#endif #include #include @@ -53,11 +53,13 @@ namespace boost i->second->unlock(); i->first->notify_all(); } +//#ifndef BOOST_NO_EXCEPTIONS for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end(); i != e; ++i) { (*i)->notify_deferred(); } +//#endif } struct thread_exit_callback_node @@ -213,8 +215,10 @@ namespace boost ~externally_launched_thread() { BOOST_ASSERT(notify.empty()); notify.clear(); +//#ifndef BOOST_NO_EXCEPTIONS BOOST_ASSERT(async_states_.empty()); async_states_.clear(); +//#endif } void run() {} @@ -498,9 +502,9 @@ namespace boost set &= set -1; } return(i); - #else + #else return (__builtin_popcount(set) ); - #endif + #endif #elif defined(__GLIBC__) return get_nprocs(); #else @@ -773,6 +777,8 @@ namespace boost current_thread_data->notify_all_at_thread_exit(&cond, lk.release()); } } + +//#ifndef BOOST_NO_EXCEPTIONS namespace detail { void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr as) @@ -784,7 +790,7 @@ namespace detail { } } } - +//#endif } diff --git a/src/win32/thread.cpp b/src/win32/thread.cpp index 53a4ce6a..9a087f1a 100644 --- a/src/win32/thread.cpp +++ b/src/win32/thread.cpp @@ -54,11 +54,13 @@ namespace boost i->second->unlock(); i->first->notify_all(); } +//#ifndef BOOST_NO_EXCEPTIONS for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end(); i != e; ++i) { (*i)->notify_deferred(); } +//#endif } } @@ -370,8 +372,10 @@ namespace boost ~externally_launched_thread() { BOOST_ASSERT(notify.empty()); notify.clear(); +//#ifndef BOOST_NO_EXCEPTIONS BOOST_ASSERT(async_states_.empty()); async_states_.clear(); +//#endif } void run()