Ticket #7238: 7238.patch
File 7238.patch, 1.7 KB (added by , 10 years ago) |
---|
-
pthread/thread.cpp
432 432 sleep_for(const chrono::nanoseconds& ns) 433 433 { 434 434 using namespace chrono; 435 if (ns >= nanoseconds::zero()) 435 boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data(); 436 437 if(thread_info) 436 438 { 439 unique_lock<mutex> lk(thread_info->sleep_mutex); 440 while(cv_status::no_timeout==thread_info->sleep_condition.wait_for(lk,ns)) {} 441 } 442 else 443 { 444 if (ns >= nanoseconds::zero()) 445 { 446 447 # if defined(BOOST_HAS_PTHREAD_DELAY_NP) 437 448 timespec ts; 438 449 ts.tv_sec = static_cast<long>(duration_cast<seconds>(ns).count()); 439 450 ts.tv_nsec = static_cast<long>((ns - seconds(ts.tv_sec)).count()); 440 441 # if defined(BOOST_HAS_PTHREAD_DELAY_NP)442 451 BOOST_VERIFY(!pthread_delay_np(&ts)); 443 # elif defined(BOOST_HAS_NANOSLEEP) 452 # elif defined(BOOST_HAS_NANOSLEEP) 453 timespec ts; 454 ts.tv_sec = static_cast<long>(duration_cast<seconds>(ns).count()); 455 ts.tv_nsec = static_cast<long>((ns - seconds(ts.tv_sec)).count()); 444 456 // nanosleep takes a timespec that is an offset, not 445 457 // an absolute time. 446 458 nanosleep(&ts, 0); 447 # else459 # else 448 460 mutex mx; 449 461 mutex::scoped_lock lock(mx); 450 462 condition_variable cond; 451 463 cond.wait_for(lock, ns); 452 # endif 464 # endif 465 } 453 466 } 454 467 } 455 468 #endif