Ticket #7045: 7045_2.patch

File 7045_2.patch, 3.9 KB (added by viboes, 10 years ago)

fixes for winows platform

  • boost/thread/detail/thread.hpp

     
    364364#endif
    365365#if defined(BOOST_THREAD_PLATFORM_WIN32)
    366366        bool timed_join(const system_time& abs_time);
    367 
     367    private:
     368        bool do_try_join_until(uintmax_t milli);
     369    public:
    368370#ifdef BOOST_THREAD_USES_CHRONO
    369         bool try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp);
    370 //        bool try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp)
    371 //        {
    372 //          if (this_thread::get_id() == get_id())
    373 //          {
    374 //            boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
    375 //          }
    376 //          detail::thread_data_ptr local_thread_info=(get_thread_info)();
    377 //          if(local_thread_info)
    378 //          {
    379 //            chrono::milliseconds rel_time= chrono::ceil<chrono::milliseconds>(tp-chrono::system_clock::now());
    380 //            if(!this_thread::interruptible_wait(local_thread_info->thread_handle,rel_time.count()))
    381 //            {
    382 //                return false;
    383 //            }
    384 //            release_handle();
    385 //          }
    386 //          return true;
    387 //        }
     371        bool try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp)
     372        {
     373          chrono::milliseconds rel_time= chrono::ceil<chrono::milliseconds>(tp-chrono::system_clock::now());
     374          return do_try_join_until(rel_time.count());
     375        }
    388376#endif
    389     public:
    390377
     378
    391379#else
    392380        bool timed_join(const system_time& abs_time)
    393381        {
  • libs/thread/src/win32/thread.cpp

     
    318318
    319319    bool thread::timed_join(boost::system_time const& wait_until)
    320320    {
    321         if (this_thread::get_id() == get_id())
    322         {
    323             boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
    324         }
    325         detail::thread_data_ptr local_thread_info=(get_thread_info)();
    326         if(local_thread_info)
    327         {
    328             if(!this_thread::interruptible_wait(local_thread_info->thread_handle,get_milliseconds_until(wait_until)))
    329             {
    330                 return false;
    331             }
    332             release_handle();
    333         }
    334         return true;
     321      return do_try_join_until(get_milliseconds_until(wait_until));
    335322    }
    336323
    337 #ifdef BOOST_THREAD_USES_CHRONO
    338 
    339     bool thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp)
     324    bool thread::do_try_join_until(uintmax_t milli)
    340325    {
    341326      if (this_thread::get_id() == get_id())
    342327      {
    343         boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
     328          boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself"));
    344329      }
    345330      detail::thread_data_ptr local_thread_info=(get_thread_info)();
    346331      if(local_thread_info)
    347332      {
    348         chrono::milliseconds rel_time= chrono::ceil<chrono::milliseconds>(tp-chrono::system_clock::now());
    349         if(!this_thread::interruptible_wait(local_thread_info->thread_handle,rel_time.count()))
    350         {
    351             return false;
    352         }
    353         release_handle();
     333          if(!this_thread::interruptible_wait(local_thread_info->thread_handle,milli))
     334          {
     335              return false;
     336          }
     337          release_handle();
    354338      }
    355339      return true;
    356340    }
    357341
    358 #endif
    359 
    360342    void thread::detach() BOOST_NOEXCEPT
    361343    {
    362344        release_handle();