![]() |
MySQL 9.3.0
Source Code Documentation
|
Defines for getting and processing the current system type programmatically. More...
#include <cassert>
#include <cstdint>
#include <ctime>
#include <limits>
#include "my_config.h"
#include <sys/time.h>
#include "my_time_t.h"
Go to the source code of this file.
Typedefs | |
using | Timeout_type = std::uint64_t |
Type alias to reduce chance of conversion errors on timeout values. More... | |
Functions | |
void | my_sleep (int64_t micro_seconds) |
Wait a given number of microseconds. More... | |
unsigned long long int | my_getsystime () |
Get high-resolution time. More... | |
void | set_timespec_nsec (struct timespec *abstime, Timeout_type nsec) |
Set the value of a timespec object to the current time plus a number of nanosconds. More... | |
void | set_timespec (struct timespec *abstime, Timeout_type sec) |
Set the value of a timespec object to the current time plus a number of seconds using seconds. More... | |
int | cmp_timespec (struct timespec *ts1, struct timespec *ts2) |
Compare two timespec structs. More... | |
unsigned long long int | diff_timespec (struct timespec *ts1, struct timespec *ts2) |
Calculate the diff between two timespec values. More... | |
time_t | my_time (int) |
Return current time. More... | |
unsigned long long int | my_micro_time () |
Return time in microseconds. More... | |
void | my_micro_time_to_timeval (std::uint64_t micro_time, my_timeval *tm) |
Convert microseconds since epoch to my_timeval. More... | |
void | my_micro_time_to_timeval (std::uint64_t micro_time, timeval *tm) |
Convert microseconds since epoch to timeval. More... | |
void | get_date (char *to, int flag, time_t date) |
Store textual representation of date in a character array. More... | |
Variables | |
constexpr const int | GETDATE_DATE_TIME = 1 |
constexpr const int | GETDATE_SHORT_DATE = 2 |
constexpr const int | GETDATE_HHMMSSTIME = 4 |
constexpr const int | GETDATE_GMT = 8 |
constexpr const int | GETDATE_FIXEDLENGTH = 16 |
constexpr const int | GETDATE_T_DELIMITER = 32 |
constexpr const int | GETDATE_SHORT_DATE_FULL_YEAR = 64 |
constexpr const timespec | TIMESPEC_POSINF |
The maximum timespec value used to represent "inifinity" (as when requesting an "infinite" timeout. More... | |
constexpr const Timeout_type | TIMEOUT_INF |
Value representing "infinite" timeout. More... | |
Defines for getting and processing the current system type programmatically.
using Timeout_type = std::uint64_t |
Type alias to reduce chance of conversion errors on timeout values.
|
inline |
Compare two timespec structs.
1 | If ts1 ends after ts2. |
-1 | If ts1 ends before ts2. |
0 | If ts1 is equal to ts2. |
|
inline |
Calculate the diff between two timespec values.
void get_date | ( | char * | to, |
int | flag, | ||
time_t | date | ||
) |
Store textual representation of date in a character array.
[out] | to | character array where date will be written |
flag | format of date: If flag & GETDATE_TIME Return date and time If flag & GETDATE_SHORT_DATE Return short date format YYMMDD If flag & GETDATE_HHMMSSTIME Return time in HHMMDD format. If flag & GETDATE_GMT Date/time in GMT If flag & GETDATE_FIXEDLENGTH Return fixed length date/time | |
date | time_t value for conversion. |
|
inline |
Get high-resolution time.
Forwards to std::chrono on Windows.
|
inline |
Return time in microseconds.
Uses std::chrono::high_resolution_clock
Number | of microseconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC) |
|
inline |
Convert microseconds since epoch to my_timeval.
micro_time | Microseconds. | |
[out] | tm | A timeval variable to write to. |
|
inline |
Convert microseconds since epoch to timeval.
Prefer
my_micro_time_to_timeval(std::uint64_t micro_time, my_timeval *tm)
which is 64 bits safe on all platforms: Window's timeval's long members are only 32 bits. Unless you need to use the host system's struct timeval, of course.
micro_time | Microseconds. | |
[out] | tm | A timeval variable to write to. |
void my_sleep | ( | int64_t | micro_seconds | ) |
Wait a given number of microseconds.
micro_seconds | number of microseconds to wait. |
|
inline |
Return current time.
Takes an int argument for backward compatibility. This argument is ignored.
current | time. |
void set_timespec | ( | struct timespec * | abstime, |
Timeout_type | sec | ||
) |
Set the value of a timespec object to the current time plus a number of seconds using seconds.
[out] | abstime | time value being modified |
sec | number of seconds to add to current time |
void set_timespec_nsec | ( | struct timespec * | abstime, |
Timeout_type | nsec | ||
) |
Set the value of a timespec object to the current time plus a number of nanosconds.
[out] | abstime | time value being modified |
nsec | number of nanoseconds to add to current time |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
Value representing "infinite" timeout.
|
constexpr |
The maximum timespec value used to represent "inifinity" (as when requesting an "infinite" timeout.