GRPC C++  1.62.0
Data Structures | Macros | Typedefs | Enumerations | Functions
time.h File Reference
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  gpr_timespec
 Analogous to struct timespec. More...
 

Macros

#define GPR_MS_PER_SEC   1000
 
#define GPR_US_PER_SEC   1000000
 
#define GPR_NS_PER_SEC   1000000000
 
#define GPR_NS_PER_MS   1000000
 
#define GPR_NS_PER_US   1000
 
#define GPR_US_PER_MS   1000
 

Typedefs

typedef struct gpr_timespec gpr_timespec
 Analogous to struct timespec. More...
 

Enumerations

enum  gpr_clock_type { GPR_CLOCK_MONOTONIC = 0, GPR_CLOCK_REALTIME, GPR_CLOCK_PRECISE, GPR_TIMESPAN }
 The clocks we support. More...
 

Functions

GPRAPI gpr_timespec gpr_time_0 (gpr_clock_type type)
 Time constants. More...
 
GPRAPI gpr_timespec gpr_inf_future (gpr_clock_type type)
 The far future. More...
 
GPRAPI gpr_timespec gpr_inf_past (gpr_clock_type type)
 The far past. More...
 
GPRAPI void gpr_time_init (void)
 initialize time subsystem More...
 
GPRAPI gpr_timespec gpr_now (gpr_clock_type clock)
 Return the current time measured from the given clocks epoch. More...
 
GPRAPI gpr_timespec gpr_convert_clock_type (gpr_timespec t, gpr_clock_type clock_type)
 Convert a timespec from one clock to another. More...
 
GPRAPI int gpr_time_cmp (gpr_timespec a, gpr_timespec b)
 Return -ve, 0, or +ve according to whether a < b, a == b, or a > b respectively. More...
 
GPRAPI gpr_timespec gpr_time_max (gpr_timespec a, gpr_timespec b)
 
GPRAPI gpr_timespec gpr_time_min (gpr_timespec a, gpr_timespec b)
 
GPRAPI gpr_timespec gpr_time_add (gpr_timespec a, gpr_timespec b)
 Add and subtract times. More...
 
GPRAPI gpr_timespec gpr_time_sub (gpr_timespec a, gpr_timespec b)
 
GPRAPI gpr_timespec gpr_time_from_micros (int64_t us, gpr_clock_type clock_type)
 Return a timespec representing a given number of time units. More...
 
GPRAPI gpr_timespec gpr_time_from_nanos (int64_t ns, gpr_clock_type clock_type)
 
GPRAPI gpr_timespec gpr_time_from_millis (int64_t ms, gpr_clock_type clock_type)
 
GPRAPI gpr_timespec gpr_time_from_seconds (int64_t s, gpr_clock_type clock_type)
 
GPRAPI gpr_timespec gpr_time_from_minutes (int64_t m, gpr_clock_type clock_type)
 
GPRAPI gpr_timespec gpr_time_from_hours (int64_t h, gpr_clock_type clock_type)
 
GPRAPI int32_t gpr_time_to_millis (gpr_timespec timespec)
 
GPRAPI int gpr_time_similar (gpr_timespec a, gpr_timespec b, gpr_timespec threshold)
 Return 1 if two times are equal or within threshold of each other, 0 otherwise. More...
 
GPRAPI void gpr_sleep_until (gpr_timespec until)
 Sleep until at least 'until' - an absolute timeout. More...
 
GPRAPI double gpr_timespec_to_micros (gpr_timespec t)
 

Macro Definition Documentation

◆ GPR_MS_PER_SEC

#define GPR_MS_PER_SEC   1000

◆ GPR_NS_PER_MS

#define GPR_NS_PER_MS   1000000

◆ GPR_NS_PER_SEC

#define GPR_NS_PER_SEC   1000000000

◆ GPR_NS_PER_US

#define GPR_NS_PER_US   1000

◆ GPR_US_PER_MS

#define GPR_US_PER_MS   1000

◆ GPR_US_PER_SEC

#define GPR_US_PER_SEC   1000000

Typedef Documentation

◆ gpr_timespec

typedef struct gpr_timespec gpr_timespec

Analogous to struct timespec.

On some machines, absolute times may be in local time.

Enumeration Type Documentation

◆ gpr_clock_type

The clocks we support.

Enumerator
GPR_CLOCK_MONOTONIC 

Monotonic clock.

Epoch undefined. Always moves forwards.

GPR_CLOCK_REALTIME 

Realtime clock.

May jump forwards or backwards. Settable by the system administrator. Has its epoch at 0:00:00 UTC 1 Jan 1970.

GPR_CLOCK_PRECISE 

CPU cycle time obtained by rdtsc instruction on x86 platforms.

Epoch undefined. Degrades to GPR_CLOCK_REALTIME on other platforms.

GPR_TIMESPAN 

Unmeasurable clock type: no base, created by taking the difference between two times.

Function Documentation

◆ gpr_convert_clock_type()

GPRAPI gpr_timespec gpr_convert_clock_type ( gpr_timespec  t,
gpr_clock_type  clock_type 
)

Convert a timespec from one clock to another.

◆ gpr_inf_future()

GPRAPI gpr_timespec gpr_inf_future ( gpr_clock_type  type)

The far future.

◆ gpr_inf_past()

GPRAPI gpr_timespec gpr_inf_past ( gpr_clock_type  type)

The far past.

◆ gpr_now()

GPRAPI gpr_timespec gpr_now ( gpr_clock_type  clock)

Return the current time measured from the given clocks epoch.

◆ gpr_sleep_until()

GPRAPI void gpr_sleep_until ( gpr_timespec  until)

Sleep until at least 'until' - an absolute timeout.

◆ gpr_time_0()

GPRAPI gpr_timespec gpr_time_0 ( gpr_clock_type  type)

Time constants.

The zero time interval.

◆ gpr_time_add()

GPRAPI gpr_timespec gpr_time_add ( gpr_timespec  a,
gpr_timespec  b 
)

Add and subtract times.

Calculations saturate at infinities.

◆ gpr_time_cmp()

GPRAPI int gpr_time_cmp ( gpr_timespec  a,
gpr_timespec  b 
)

Return -ve, 0, or +ve according to whether a < b, a == b, or a > b respectively.


◆ gpr_time_from_hours()

GPRAPI gpr_timespec gpr_time_from_hours ( int64_t  h,
gpr_clock_type  clock_type 
)

◆ gpr_time_from_micros()

GPRAPI gpr_timespec gpr_time_from_micros ( int64_t  us,
gpr_clock_type  clock_type 
)

Return a timespec representing a given number of time units.

INT64_MIN is interpreted as gpr_inf_past, and INT64_MAX as gpr_inf_future.

◆ gpr_time_from_millis()

GPRAPI gpr_timespec gpr_time_from_millis ( int64_t  ms,
gpr_clock_type  clock_type 
)

◆ gpr_time_from_minutes()

GPRAPI gpr_timespec gpr_time_from_minutes ( int64_t  m,
gpr_clock_type  clock_type 
)

◆ gpr_time_from_nanos()

GPRAPI gpr_timespec gpr_time_from_nanos ( int64_t  ns,
gpr_clock_type  clock_type 
)

◆ gpr_time_from_seconds()

GPRAPI gpr_timespec gpr_time_from_seconds ( int64_t  s,
gpr_clock_type  clock_type 
)

◆ gpr_time_init()

GPRAPI void gpr_time_init ( void  )

initialize time subsystem

◆ gpr_time_max()

GPRAPI gpr_timespec gpr_time_max ( gpr_timespec  a,
gpr_timespec  b 
)

◆ gpr_time_min()

GPRAPI gpr_timespec gpr_time_min ( gpr_timespec  a,
gpr_timespec  b 
)

◆ gpr_time_similar()

GPRAPI int gpr_time_similar ( gpr_timespec  a,
gpr_timespec  b,
gpr_timespec  threshold 
)

Return 1 if two times are equal or within threshold of each other, 0 otherwise.

◆ gpr_time_sub()

GPRAPI gpr_timespec gpr_time_sub ( gpr_timespec  a,
gpr_timespec  b 
)

◆ gpr_time_to_millis()

GPRAPI int32_t gpr_time_to_millis ( gpr_timespec  timespec)

◆ gpr_timespec_to_micros()

GPRAPI double gpr_timespec_to_micros ( gpr_timespec  t)