8#ifndef INCLUDED_BSLMT_CHRONOUTIL
9#define INCLUDED_BSLMT_CHRONOUTIL
219#include <bslscm_version.h>
226#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
227#include <bsl_chrono.h>
247 template <
class REP_TYPE,
class PERIOD_TYPE>
249 const bsl::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration);
253 template <
class CLOCK>
270 template <
class PRIMITIVE,
class CLOCK,
class DURATION>
273 const bsl::chrono::time_point<CLOCK, DURATION>& absTime);
289 template <
class PRIMITIVE,
class ARG_TYPE,
class CLOCK,
class DURATION>
293 const bsl::chrono::time_point<CLOCK, DURATION>& absTime);
305template <
class REP_TYPE,
class PERIOD_TYPE>
308 const bsl::chrono::duration<REP_TYPE, PERIOD_TYPE>& duration)
314 bsl::chrono::seconds wholeSecs =
315 duration_cast<bsl::chrono::seconds>(duration);
316 nanoseconds nanoSecs = duration_cast<nanoseconds>(duration - wholeSecs);
318 static_cast<int>(nanoSecs.count()));
321template <
class CLOCK>
330bool ChronoUtil::isMatchingClock<bsl::chrono::system_clock>(
338bool ChronoUtil::isMatchingClock<bsl::chrono::steady_clock>(
344template <
class PRIMITIVE,
class CLOCK,
class DURATION>
346 PRIMITIVE *primitive,
347 const bsl::chrono::time_point<CLOCK, DURATION>& absTime)
349 if (ChronoUtil::isMatchingClock<CLOCK>(primitive->clockType())) {
350 return primitive->timedWait(
354 typename CLOCK::time_point now = CLOCK::now();
360 while (absTime > now) {
364 ret = primitive->timedWait(ti);
365 if (PRIMITIVE::e_TIMED_OUT != ret) {
370 return PRIMITIVE::e_TIMED_OUT;
374template <
class PRIMITIVE,
class ARG_TYPE,
class CLOCK,
class DURATION>
376 PRIMITIVE *primitive,
378 const bsl::chrono::time_point<CLOCK, DURATION>& absTime)
380 if (ChronoUtil::isMatchingClock<CLOCK>(primitive->clockType())) {
381 return primitive->timedWait(
386 typename CLOCK::time_point now = CLOCK::now();
392 while (absTime > now) {
396 ret = primitive->timedWait(argument, ti);
397 if (PRIMITIVE::e_TIMED_OUT != ret) {
402 return PRIMITIVE::e_TIMED_OUT;
Definition bsls_timeinterval.h:301
BSLS_KEYWORD_CONSTEXPR_CPP14 TimeInterval & addDuration(const std::chrono::duration< REP_TYPE, PERIOD_TYPE > &duration, typename std::enable_if< TimeInterval_DurationTraits< REP_TYPE, PERIOD_TYPE >::k_IMPLICIT_CONVERSION_ENABLED, int >::type *=0)
Definition bsls_timeinterval.h:1226
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslstl_chrono.h:146
Definition bslmt_barrier.h:344
Definition bslmt_chronoutil.h:238
static bool isMatchingClock(bsls::SystemClockType::Enum clockType)
Definition bslmt_chronoutil.h:323
static int timedWait(PRIMITIVE *primitive, const bsl::chrono::time_point< CLOCK, DURATION > &absTime)
Definition bslmt_chronoutil.h:345
static bsls::TimeInterval durationToTimeInterval(const bsl::chrono::duration< REP_TYPE, PERIOD_TYPE > &duration)
Definition bslmt_chronoutil.h:307
Enum
Definition bsls_systemclocktype.h:117
@ e_MONOTONIC
Definition bsls_systemclocktype.h:126
@ e_REALTIME
Definition bsls_systemclocktype.h:120
static TimeInterval now(SystemClockType::Enum clockType)
Definition bsls_systemtime.h:175