2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-10 11:52:10 +00:00

Improved the timespec implementation

* Added a constructor to timespec_duration, real_timespec_timepoint, and mono_timespec_timepoint that takes an intmax_t representing the number of nanoseconds in the timespec.
* Added a getNs() function to timespec_duration, real_timespec_timepoint, and mono_timespec_timepoint that returns an intmax_t representing the number of nanoseconds in the timespec.
* Added a timespec_milliseconds() function that takes an integer representing milliseconds and returns a timespec_duration.
* Removed some unnecessary BOOST_SYMBOL_VISIBLE declarations.
* Removed the unnecessary d100 variable declarations.
This commit is contained in:
Austin Beer
2017-09-20 18:50:25 -06:00
parent bad686d620
commit de7e354a8e
4 changed files with 51 additions and 53 deletions

View File

@@ -468,15 +468,12 @@ namespace boost
condition_variable cond;
#if defined(CLOCK_MONOTONIC) && !defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC
const timespec maxSleepTs = {0, 100000000}; // 100 milliseconds
const detail::timespec_duration maxSleep(maxSleepTs);
const detail::mono_timespec_timepoint& ts2 = detail::mono_timespec_clock::now() + ts;
detail::timespec_duration d = ts;
while (d > detail::timespec_duration::zero())
{
detail::timespec_duration d100 = (std::min)(d, maxSleep);
cond.do_wait_until(lock, detail::internal_timespec_clock::now() + d100);
d = (std::min)(d, detail::timespec_milliseconds(100));
cond.do_wait_until(lock, detail::internal_timespec_clock::now() + d);
d = ts2 - detail::mono_timespec_clock::now();
}
#else