Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85815 - in branches/release: boost/thread boost/thread/detail boost/thread/win32 libs/thread/src/pthread libs/thread/src/win32
From: vicente.botet_at_[hidden]
Date: 2013-09-21 16:45:07


Author: viboes
Date: 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013)
New Revision: 85815
URL: http://svn.boost.org/trac/boost/changeset/85815

Log:
Thread: merge from trunk to fix 8070 and possibly 7461.

Text files modified:
   branches/release/boost/thread/detail/thread.hpp | 13 +++++++++++++
   branches/release/boost/thread/future.hpp | 13 +++++++------
   branches/release/boost/thread/win32/condition_variable.hpp | 11 +++++------
   branches/release/boost/thread/win32/mfc_thread_init.hpp | 27 +++++++++++++--------------
   branches/release/boost/thread/win32/thread_data.hpp | 2 +-
   branches/release/boost/thread/win32/thread_primitives.hpp | 5 +++--
   branches/release/libs/thread/src/pthread/thread.cpp | 37 +++++++++++++++++++++++++++++--------
   branches/release/libs/thread/src/win32/thread.cpp | 19 ++++++++++++++++++-
   8 files changed, 89 insertions(+), 38 deletions(-)

Modified: branches/release/boost/thread/detail/thread.hpp
==============================================================================
--- branches/release/boost/thread/detail/thread.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/detail/thread.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -826,6 +826,19 @@
         };
 
         void BOOST_THREAD_DECL add_thread_exit_function(thread_exit_function_base*);
+ struct shared_state_base;
+#if defined(BOOST_THREAD_PLATFORM_WIN32)
+ inline void make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
+ {
+ detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
+ if(current_thread_data)
+ {
+ current_thread_data->make_ready_at_thread_exit(as);
+ }
+ }
+#else
+ void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as);
+#endif
     }
 
     namespace this_thread

Modified: branches/release/boost/thread/future.hpp
==============================================================================
--- branches/release/boost/thread/future.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/future.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -418,7 +418,7 @@
               {
                   throw_exception(promise_already_satisfied());
               }
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
             }
 #endif
 
@@ -431,7 +431,8 @@
               }
               exception=e;
               this->is_constructed = true;
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
+
             }
 
             bool has_value() const
@@ -688,7 +689,7 @@
               result.reset(new T(result_));
 
               this->is_constructed = true;
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
             }
             //void set_value_at_thread_exit(BOOST_THREAD_RV_REF(T) result_)
             void set_value_at_thread_exit(rvalue_source_type result_)
@@ -699,7 +700,7 @@
               result.reset(new T(boost::move(result_)));
               //future_traits<T>::init(result,static_cast<rvalue_source_type>(result_));
               this->is_constructed = true;
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
             }
 
 
@@ -760,7 +761,7 @@
               //future_traits<T>::init(result,result_);
               result= &result_;
               this->is_constructed = true;
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
             }
 
         private:
@@ -806,7 +807,7 @@
                   throw_exception(promise_already_satisfied());
               }
               this->is_constructed = true;
- get_current_thread_data()->make_ready_at_thread_exit(shared_from_this());
+ detail::make_ready_at_thread_exit(shared_from_this());
             }
         private:
             shared_state(shared_state const&);

Modified: branches/release/boost/thread/win32/condition_variable.hpp
==============================================================================
--- branches/release/boost/thread/win32/condition_variable.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/win32/condition_variable.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -191,18 +191,17 @@
             struct entry_manager
             {
                 entry_ptr const entry;
+ boost::mutex& internal_mutex;
 
                 BOOST_THREAD_NO_COPYABLE(entry_manager)
- entry_manager(entry_ptr const& entry_):
- entry(entry_)
+ entry_manager(entry_ptr const& entry_, boost::mutex& mutex_):
+ entry(entry_), internal_mutex(mutex_)
                 {}
 
                 ~entry_manager()
                 {
- //if(! entry->is_notified()) // several regression #7657
- {
+ boost::lock_guard<boost::mutex> internal_lock(internal_mutex);
                     entry->remove_waiter();
- }
                 }
 
                 list_entry* operator->()
@@ -218,7 +217,7 @@
             {
                 relocker<lock_type> locker(lock);
 
- entry_manager entry(get_wait_entry());
+ entry_manager entry(get_wait_entry(), internal_mutex);
 
                 locker.unlock();
 

Modified: branches/release/boost/thread/win32/mfc_thread_init.hpp
==============================================================================
--- branches/release/boost/thread/win32/mfc_thread_init.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/win32/mfc_thread_init.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -9,33 +9,32 @@
 
 // check if we use MFC
 #ifdef _AFXDLL
-# if defined(_AFXEXT)
+# if defined(_AFXEXT)
 
 // can't use ExtRawDllMain from afxdllx.h as it also defines the symbol _pRawDllMain
 extern "C"
 inline BOOL WINAPI ExtRawDllMain(HINSTANCE, DWORD dwReason, LPVOID)
 {
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- // save critical data pointers before running the constructors
- AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
- pModuleState->m_pClassInit = pModuleState->m_classList;
- pModuleState->m_pFactoryInit = pModuleState->m_factoryList;
- pModuleState->m_classList.m_pHead = NULL;
- pModuleState->m_factoryList.m_pHead = NULL;
- }
- return TRUE; // ok
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ // save critical data pointers before running the constructors
+ AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
+ pModuleState->m_pClassInit = pModuleState->m_classList;
+ pModuleState->m_pFactoryInit = pModuleState->m_factoryList;
+ pModuleState->m_classList.m_pHead = NULL;
+ pModuleState->m_factoryList.m_pHead = NULL;
+ }
+ return TRUE; // ok
 }
 
 extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID) = &ExtRawDllMain;
 
-# elif defined(_USRDLL)
+# elif defined(_USRDLL)
 
 extern "C" BOOL WINAPI RawDllMain(HANDLE, DWORD dwReason, LPVOID);
 extern "C" __declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID) = &RawDllMain;
 
-# endif
+# endif
 #endif
 
-
 #endif

Modified: branches/release/boost/thread/win32/thread_data.hpp
==============================================================================
--- branches/release/boost/thread/win32/thread_data.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/win32/thread_data.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -148,7 +148,7 @@
 
             virtual void run()=0;
 
- void notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+ virtual void notify_all_at_thread_exit(condition_variable* cv, mutex* m)
             {
               notify.push_back(std::pair<condition_variable*, mutex*>(cv, m));
             }

Modified: branches/release/boost/thread/win32/thread_primitives.hpp
==============================================================================
--- branches/release/boost/thread/win32/thread_primitives.hpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/boost/thread/win32/thread_primitives.hpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -15,11 +15,12 @@
 #include <boost/assert.hpp>
 #include <boost/thread/exceptions.hpp>
 #include <boost/detail/interlocked.hpp>
+//#include <boost/detail/win/synchronization.hpp>
 #include <algorithm>
 
 #ifndef BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
-#if _WIN32_WINNT >= 0x0600
-//#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
+#if _WIN32_WINNT >= 0x0600 && ! defined _WIN32_WINNT_WS08
+#define BOOST_THREAD_WIN32_HAS_GET_TICK_COUNT_64
 #endif
 #endif
 

Modified: branches/release/libs/thread/src/pthread/thread.cpp
==============================================================================
--- branches/release/libs/thread/src/pthread/thread.cpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/libs/thread/src/pthread/thread.cpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -187,7 +187,9 @@
                 return 0;
             }
         }
-
+ }
+ namespace detail
+ {
         struct externally_launched_thread:
             detail::thread_data_base
         {
@@ -197,7 +199,12 @@
                 interrupt_enabled=false;
 #endif
             }
-
+ ~externally_launched_thread() {
+ BOOST_ASSERT(notify.empty());
+ notify.clear();
+ BOOST_ASSERT(async_states_.empty());
+ async_states_.clear();
+ }
             void run()
             {}
             void notify_all_at_thread_exit(condition_variable*, mutex*)
@@ -208,18 +215,18 @@
             void operator=(externally_launched_thread&);
         };
 
- detail::thread_data_base* make_external_thread_data()
+ thread_data_base* make_external_thread_data()
         {
- detail::thread_data_base* const me(new externally_launched_thread());
+ thread_data_base* const me(new externally_launched_thread());
             me->self.reset(me);
             set_current_thread_data(me);
             return me;
         }
 
 
- detail::thread_data_base* get_or_make_current_thread_data()
+ thread_data_base* get_or_make_current_thread_data()
         {
- detail::thread_data_base* current_thread_data(detail::get_current_thread_data());
+ thread_data_base* current_thread_data(get_current_thread_data());
             if(!current_thread_data)
             {
                 current_thread_data=make_external_thread_data();
@@ -701,8 +708,11 @@
 
         void erase_tss_node(void const* key)
         {
- detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data());
- current_thread_data->tss_data.erase(key);
+ detail::thread_data_base* const current_thread_data(get_current_thread_data());
+ if(current_thread_data)
+ {
+ current_thread_data->tss_data.erase(key);
+ }
         }
 
         void set_tss_data(void const* key,
@@ -740,6 +750,17 @@
         current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
       }
     }
+namespace detail {
+
+ void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
+ {
+ detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
+ if(current_thread_data)
+ {
+ current_thread_data->make_ready_at_thread_exit(as);
+ }
+ }
+}
 
 
 

Modified: branches/release/libs/thread/src/win32/thread.cpp
==============================================================================
--- branches/release/libs/thread/src/win32/thread.cpp Sat Sep 21 16:33:14 2013 (r85814)
+++ branches/release/libs/thread/src/win32/thread.cpp 2013-09-21 16:45:06 EDT (Sat, 21 Sep 2013) (r85815)
@@ -279,6 +279,12 @@
                 interruption_enabled=false;
 #endif
             }
+ ~externally_launched_thread() {
+ BOOST_ASSERT(notify.empty());
+ notify.clear();
+ BOOST_ASSERT(async_states_.empty());
+ async_states_.clear();
+ }
 
             void run()
             {}
@@ -430,7 +436,7 @@
                 LARGE_INTEGER due_time={{0,0}};
                 if(target_time.relative)
                 {
- unsigned long const elapsed_milliseconds=GetTickCount()-target_time.start;
+ unsigned long const elapsed_milliseconds=detail::win32::GetTickCount64()-target_time.start;
                     LONGLONG const remaining_milliseconds=(target_time.milliseconds-elapsed_milliseconds);
                     LONGLONG const hundred_nanoseconds_in_one_millisecond=10000;
 
@@ -748,5 +754,16 @@
         current_thread_data->notify_all_at_thread_exit(&cond, lk.release());
       }
     }
+//namespace detail {
+//
+// void BOOST_THREAD_DECL make_ready_at_thread_exit(shared_ptr<shared_state_base> as)
+// {
+// detail::thread_data_base* const current_thread_data(detail::get_current_thread_data());
+// if(current_thread_data)
+// {
+// current_thread_data->make_ready_at_thread_exit(as);
+// }
+// }
+//}
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk