]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/thread/src/win32/thread.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / thread / src / win32 / thread.cpp
index 7e2c21bc0d1193e3b04613a6ca48c787d97fde9b..5252221362c3117b9a3dab68e4464da313343e4b 100644 (file)
@@ -3,7 +3,7 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 // (C) Copyright 2007 Anthony Williams
 // (C) Copyright 2007 David Deakins
-// (C) Copyright 2011-2013 Vicente J. Botet Escriba
+// (C) Copyright 2011-2017 Vicente J. Botet Escriba
 
 //#define BOOST_THREAD_VERSION 3
 
@@ -57,7 +57,7 @@ namespace boost
         for (async_states_t::iterator i = async_states_.begin(), e = async_states_.end();
                 i != e; ++i)
         {
-            (*i)->make_ready();
+            (*i)->notify_deferred();
         }
     }
   }
@@ -154,8 +154,6 @@ namespace boost
             return ret;
         }
 
-        //typedef void* uintptr_t;
-
         inline uintptr_t _beginthreadex(void* security, unsigned stack_size, unsigned (__stdcall* start_address)(void*),
                                               void* arglist, unsigned initflag, unsigned* thrdaddr)
         {
@@ -299,12 +297,7 @@ namespace boost
             BOOST_CATCH(thread_interrupted const&)
             {
             }
-// Removed as it stops the debugger identifying the cause of the exception
-// Unhandled exceptions still cause the application to terminate
-//             BOOST_CATCH(...)
-//             {
-//                 std::terminate();
-//             }
+            // Unhandled exceptions still cause the application to terminate
             BOOST_CATCH_END
 #endif
             run_thread_exit_callbacks();
@@ -322,7 +315,6 @@ namespace boost
          if (!thread_info->thread_handle.start(&thread_start_function, thread_info.get(), &thread_info->id))
          {
              intrusive_ptr_release(thread_info.get());
-//           boost::throw_exception(thread_resource_error());
              return false;
          }
          return true;
@@ -331,7 +323,6 @@ namespace boost
         if(!new_thread)
         {
             return false;
-//            boost::throw_exception(thread_resource_error());
         }
         intrusive_ptr_add_ref(thread_info.get());
         thread_info->thread_handle=(detail::win32::handle)(new_thread);
@@ -347,12 +338,11 @@ namespace boost
         attr;
         return start_thread_noexcept();
 #else
-      //uintptr_t const new_thread=_beginthreadex(attr.get_security(),attr.get_stack_size(),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
-      uintptr_t const new_thread=_beginthreadex(0,static_cast<unsigned int>(attr.get_stack_size()),&thread_start_function,thread_info.get(),CREATE_SUSPENDED,&thread_info->id);
+      uintptr_t const new_thread=_beginthreadex(0,static_cast<unsigned int>(attr.get_stack_size()),&thread_start_function,thread_info.get(),
+                                                CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, &thread_info->id);
       if(!new_thread)
       {
         return false;
-//          boost::throw_exception(thread_resource_error());
       }
       intrusive_ptr_add_ref(thread_info.get());
       thread_info->thread_handle=(detail::win32::handle)(new_thread);
@@ -508,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::win32::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0);
+        return local_thread_info.get() && (detail::winapi::WaitForSingleObjectEx(local_thread_info->interruption_handle,0,0)==0);
     }
 
 #endif
@@ -644,7 +634,6 @@ namespace boost
                     } Detailed;
                 } Reason;
             } REASON_CONTEXT, *PREASON_CONTEXT;
-            //static REASON_CONTEXT default_reason_context={0/*POWER_REQUEST_CONTEXT_VERSION*/, 0x00000001/*POWER_REQUEST_CONTEXT_SIMPLE_STRING*/, (LPWSTR)L"generic"};
             typedef BOOL (WINAPI *setwaitabletimerex_t)(HANDLE, const LARGE_INTEGER *, LONG, PTIMERAPCROUTINE, LPVOID, PREASON_CONTEXT, ULONG);
             static inline BOOL WINAPI SetWaitableTimerEx_emulation(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay)
             {
@@ -714,7 +703,6 @@ namespace boost
                     if(time_left.milliseconds/20>tolerable)  // 5%
                         tolerable=time_left.milliseconds/20;
                     LARGE_INTEGER due_time=get_due_time(target_time);
-                    //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0;
                     bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0;
                     if(set_time_succeeded)
                     {
@@ -738,7 +726,7 @@ namespace boost
 
                 if(handle_count)
                 {
-                    unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
+                    unsigned long const notified_index=detail::winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
                     if(notified_index<handle_count)
                     {
                         if(notified_index==wait_handle_index)
@@ -748,7 +736,7 @@ namespace boost
 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
                         else if(notified_index==interruption_index)
                         {
-                            detail::win32::ResetEvent(detail::get_current_thread_data()->interruption_handle);
+                            detail::winapi::ResetEvent(detail::get_current_thread_data()->interruption_handle);
                             throw thread_interrupted();
                         }
 #endif
@@ -799,7 +787,6 @@ namespace boost
                     if(time_left.milliseconds/20>tolerable)  // 5%
                         tolerable=time_left.milliseconds/20;
                     LARGE_INTEGER due_time=get_due_time(target_time);
-                    //bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,&detail_::default_reason_context,tolerable)!=0;
                     bool const set_time_succeeded=detail_::SetWaitableTimerEx()(timer_handle,&due_time,0,0,0,NULL,tolerable)!=0;
                     if(set_time_succeeded)
                     {
@@ -823,7 +810,7 @@ namespace boost
 
                 if(handle_count)
                 {
-                    unsigned long const notified_index=detail::win32::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
+                    unsigned long const notified_index=detail::winapi::WaitForMultipleObjectsEx(handle_count,handles,false,using_timer?INFINITE:time_left.milliseconds, 0);
                     if(notified_index<handle_count)
                     {
                         if(notified_index==wait_handle_index)
@@ -860,7 +847,7 @@ namespace boost
                 return current_thread_data->id;
             }
 #endif
-            return detail::win32::GetCurrentThreadId();
+            return detail::winapi::GetCurrentThreadId();
 #else
             return thread::id(get_or_make_current_thread_data());
 #endif
@@ -871,7 +858,7 @@ namespace boost
         {
             if(interruption_enabled() && interruption_requested())
             {
-                detail::win32::ResetEvent(detail::get_current_thread_data()->interruption_handle);
+                detail::winapi::ResetEvent(detail::get_current_thread_data()->interruption_handle);
                 throw thread_interrupted();
             }
         }
@@ -883,7 +870,7 @@ namespace boost
 
         bool interruption_requested() BOOST_NOEXCEPT
         {
-            return detail::get_current_thread_data() && (detail::win32::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0);
+            return detail::get_current_thread_data() && (detail::winapi::WaitForSingleObjectEx(detail::get_current_thread_data()->interruption_handle,0,0)==0);
         }
 #endif
 
@@ -1028,16 +1015,5 @@ namespace boost
         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);
-//      }
-//    }
-//}
 }