proxygen
folly::chrono Namespace Reference

Namespaces

 detail
 

Classes

struct  coarse_steady_clock
 

Functions

template<typename To , typename Rep , typename Period , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr To ceil (std::chrono::duration< Rep, Period > const &d)
 
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr std::chrono::time_point< Clock, To > ceil (std::chrono::time_point< Clock, Duration > const &tp)
 
template<typename To , typename Rep , typename Period , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr To floor (std::chrono::duration< Rep, Period > const &d)
 
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr std::chrono::time_point< Clock, To > floor (std::chrono::time_point< Clock, Duration > const &tp)
 
template<typename To , typename Rep , typename Period , typename = typename std::enable_if< detail::is_duration<To>::value && !std::chrono::treat_as_floating_point<typename To::rep>::value>::type>
constexpr To round (std::chrono::duration< Rep, Period > const &d)
 
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if< detail::is_duration<To>::value && !std::chrono::treat_as_floating_point<typename To::rep>::value>::type>
constexpr std::chrono::time_point< Clock, To > round (std::chrono::time_point< Clock, Duration > const &tp)
 
static int64_t clock_gettime_ns_fallback (clockid_t clock)
 

Variables

int(* clock_gettime )(clockid_t, timespec *ts) = &::clock_gettime
 
int64_t(* clock_gettime_ns )(clockid_t) = &clock_gettime_ns_fallback
 

Function Documentation

template<typename To , typename Rep , typename Period , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr To folly::chrono::ceil ( std::chrono::duration< Rep, Period > const &  d)

Definition at line 91 of file Chrono.h.

References folly::chrono::detail::ceil_impl(), type, and value.

Referenced by proxygen::HeaderTable::add().

91  {
92  return detail::ceil_impl(d, std::chrono::duration_cast<To>(d));
93 }
constexpr To ceil_impl(Duration const &d, To const &t)
Definition: Chrono.h:59
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr std::chrono::time_point<Clock, To> folly::chrono::ceil ( std::chrono::time_point< Clock, Duration > const &  tp)

Definition at line 102 of file Chrono.h.

References type, and value.

103  {
104  return std::chrono::time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
105 }
static int64_t folly::chrono::clock_gettime_ns_fallback ( clockid_t  clock)
static

Definition at line 33 of file ClockGettimeWrappers.cpp.

References clock_gettime, and UNLIKELY.

33  {
34  struct timespec ts;
35  int r = clock_gettime(clock, &ts);
36  if (UNLIKELY(r != 0)) {
37  // Mimic what __clock_gettime_ns does (even though this can be a legit
38  // value).
39  return -1;
40  }
41  std::chrono::nanoseconds result =
42  std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec);
43  return result.count();
44 }
int(* clock_gettime)(clockid_t, timespec *ts)
#define UNLIKELY(x)
Definition: Likely.h:48
template<typename To , typename Rep , typename Period , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr To folly::chrono::floor ( std::chrono::duration< Rep, Period > const &  d)

Definition at line 114 of file Chrono.h.

References folly::chrono::detail::floor_impl(), type, and value.

Referenced by fizz::test::chunkIOBuf().

114  {
115  return detail::floor_impl(d, std::chrono::duration_cast<To>(d));
116 }
constexpr To floor_impl(Duration const &d, To const &t)
Definition: Chrono.h:64
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if<detail::is_duration<To>::value>::type>
constexpr std::chrono::time_point<Clock, To> folly::chrono::floor ( std::chrono::time_point< Clock, Duration > const &  tp)

Definition at line 125 of file Chrono.h.

References type, and value.

126  {
127  return std::chrono::time_point<Clock, To>{floor<To>(tp.time_since_epoch())};
128 }
template<typename To , typename Rep , typename Period , typename = typename std::enable_if< detail::is_duration<To>::value && !std::chrono::treat_as_floating_point<typename To::rep>::value>::type>
constexpr To folly::chrono::round ( std::chrono::duration< Rep, Period > const &  d)

Definition at line 139 of file Chrono.h.

References folly::chrono::detail::round_impl(), type, and value.

Referenced by folly::constexpr_ceil(), fizz::HkdfImpl< Hash >::expand(), Run(), folly::TEST(), and TEST_F().

139  {
140  return detail::round_impl(d, floor<To>(d));
141 }
constexpr To round_impl(Duration const &d, To const &t0)
Definition: Chrono.h:79
template<typename To , typename Clock , typename Duration , typename = typename std::enable_if< detail::is_duration<To>::value && !std::chrono::treat_as_floating_point<typename To::rep>::value>::type>
constexpr std::chrono::time_point<Clock, To> folly::chrono::round ( std::chrono::time_point< Clock, Duration > const &  tp)

Definition at line 152 of file Chrono.h.

References chrono.

153  {
154  return std::chrono::time_point<Clock, To>{round<To>(tp.time_since_epoch())};
155 }

Variable Documentation

int(* folly::chrono::clock_gettime)(clockid_t, timespec *ts) = &::clock_gettime
int64_t(* folly::chrono::clock_gettime_ns)(clockid_t) = &clock_gettime_ns_fallback

Definition at line 49 of file ClockGettimeWrappers.cpp.