diff options
Diffstat (limited to '3rdParty/Boost/src/libs/thread/src/win32/thread.cpp')
-rw-r--r-- | 3rdParty/Boost/src/libs/thread/src/win32/thread.cpp | 88 |
1 files changed, 57 insertions, 31 deletions
diff --git a/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp index b85e650..05c7a6c 100644 --- a/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp +++ b/3rdParty/Boost/src/libs/thread/src/win32/thread.cpp @@ -56,7 +56,10 @@ namespace boost void set_current_thread_data(detail::thread_data_base* new_data) { boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key); - BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); + if(current_thread_tls_key) + BOOST_VERIFY(TlsSetValue(current_thread_tls_key,new_data)); + else + boost::throw_exception(thread_resource_error()); } #ifdef BOOST_NO_THREADEX @@ -221,7 +224,15 @@ namespace boost void make_external_thread_data() { externally_launched_thread* me=detail::heap_new<externally_launched_thread>(); - set_current_thread_data(me); + try + { + set_current_thread_data(me); + } + catch(...) + { + detail::heap_delete(me); + throw; + } } detail::thread_data_base* get_or_make_current_thread_data() @@ -244,17 +255,17 @@ namespace boost thread::id thread::get_id() const { - return thread::id(get_thread_info()); + return thread::id((get_thread_info)()); } bool thread::joinable() const { - return get_thread_info(); + return (get_thread_info)(); } void thread::join() { - detail::thread_data_ptr local_thread_info=get_thread_info(); + detail::thread_data_ptr local_thread_info=(get_thread_info)(); if(local_thread_info) { this_thread::interruptible_wait(local_thread_info->thread_handle,detail::timeout::sentinel()); @@ -264,7 +275,7 @@ namespace boost bool thread::timed_join(boost::system_time const& wait_until) { - detail::thread_data_ptr local_thread_info=get_thread_info(); + detail::thread_data_ptr local_thread_info=(get_thread_info)(); if(local_thread_info) { if(!this_thread::interruptible_wait(local_thread_info->thread_handle,get_milliseconds_until(wait_until))) @@ -283,13 +294,12 @@ namespace boost void thread::release_handle() { - lock_guard<mutex> l1(thread_info_mutex); thread_info=0; } void thread::interrupt() { - detail::thread_data_ptr local_thread_info=get_thread_info(); + detail::thread_data_ptr local_thread_info=(get_thread_info)(); if(local_thread_info) { local_thread_info->interrupt(); @@ -298,26 +308,25 @@ namespace boost bool thread::interruption_requested() const { - detail::thread_data_ptr local_thread_info=get_thread_info(); + detail::thread_data_ptr local_thread_info=(get_thread_info)(); return local_thread_info.get() && (detail::win32::WaitForSingleObject(local_thread_info->interruption_handle,0)==0); } unsigned thread::hardware_concurrency() { - SYSTEM_INFO info={0}; + SYSTEM_INFO info={{0}}; GetSystemInfo(&info); return info.dwNumberOfProcessors; } thread::native_handle_type thread::native_handle() { - detail::thread_data_ptr local_thread_info=get_thread_info(); + detail::thread_data_ptr local_thread_info=(get_thread_info)(); return local_thread_info?(detail::win32::handle)local_thread_info->thread_handle:detail::win32::invalid_handle_value; } - detail::thread_data_ptr thread::get_thread_info() const + detail::thread_data_ptr thread::get_thread_info BOOST_PREVENT_MACRO_SUBSTITUTION () const { - boost::mutex::scoped_lock l(thread_info_mutex); return thread_info; } @@ -327,7 +336,7 @@ namespace boost { LARGE_INTEGER get_due_time(detail::timeout const& target_time) { - LARGE_INTEGER due_time={0}; + LARGE_INTEGER due_time={{0}}; if(target_time.relative) { unsigned long const elapsed_milliseconds=GetTickCount()-target_time.start; @@ -356,7 +365,23 @@ namespace boost else { long const hundred_nanoseconds_in_one_second=10000000; - due_time.QuadPart+=target_time.abs_time.time_of_day().fractional_seconds()*(hundred_nanoseconds_in_one_second/target_time.abs_time.time_of_day().ticks_per_second()); + posix_time::time_duration::tick_type const ticks_per_second= + target_time.abs_time.time_of_day().ticks_per_second(); + if(ticks_per_second>hundred_nanoseconds_in_one_second) + { + posix_time::time_duration::tick_type const + ticks_per_hundred_nanoseconds= + ticks_per_second/hundred_nanoseconds_in_one_second; + due_time.QuadPart+= + target_time.abs_time.time_of_day().fractional_seconds()/ + ticks_per_hundred_nanoseconds; + } + else + { + due_time.QuadPart+= + target_time.abs_time.time_of_day().fractional_seconds()* + (hundred_nanoseconds_in_one_second/ticks_per_second); + } } } return due_time; @@ -526,8 +551,8 @@ namespace boost { detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); thread_exit_callback_node* const new_node= - heap_new<thread_exit_callback_node>(func, - current_thread_data->thread_exit_callbacks); + heap_new<thread_exit_callback_node>( + func,current_thread_data->thread_exit_callbacks); current_thread_data->thread_exit_callbacks=new_node; } @@ -569,30 +594,31 @@ namespace boost current_node->func=func; current_node->value=tss_data; } - else + else if(func && tss_data) { detail::thread_data_base* const current_thread_data(get_or_make_current_thread_data()); - tss_data_node* const new_node=heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data); + tss_data_node* const new_node= + heap_new<tss_data_node>(key,func,tss_data,current_thread_data->tss_data); current_thread_data->tss_data=new_node; } } } -} + BOOST_THREAD_DECL void __cdecl on_process_enter() + {} + BOOST_THREAD_DECL void __cdecl on_thread_enter() + {} -extern "C" BOOST_THREAD_DECL void on_process_enter() -{} + BOOST_THREAD_DECL void __cdecl on_process_exit() + { + boost::cleanup_tls_key(); + } -extern "C" BOOST_THREAD_DECL void on_thread_enter() -{} + BOOST_THREAD_DECL void __cdecl on_thread_exit() + { + boost::run_thread_exit_callbacks(); + } -extern "C" BOOST_THREAD_DECL void on_process_exit() -{ - boost::cleanup_tls_key(); } -extern "C" BOOST_THREAD_DECL void on_thread_exit() -{ - boost::run_thread_exit_callbacks(); -} |