AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Classes | Functions | Variables
alexaClientSDK::avsCommon::utils::timing Namespace Reference

Namespaces

 test
 

Classes

class  MultiTimer
 
class  SafeCTimeAccess
 
class  Stopwatch
 
class  TimePoint
 
class  Timer
 
class  TimerDelegate
 
class  TimerDelegateFactory
 
class  TimeUtils
 

Functions

std::chrono::steady_clock::time_point getDistantFuture ()
 
static const std::string TAG ("MultiTimer")
 String to identify log entries originating from this file. More...
 
static const std::string TAG ("Stopwatch")
 String to identify log entries originating from this file. More...
 
static std::chrono::milliseconds elapsed (std::chrono::steady_clock::time_point later, std::chrono::steady_clock::time_point earlier)
 
static const std::string TAG ("TimePoint")
 String to identify log entries originating from this file. More...
 
static const std::string TAG (Timer::getTag())
 String to identify log entries originating from this file. More...
 
static const std::string TAG ("TimeUtils")
 String to identify log entries originating from this file. More...
 
static bool convertToLocalTimeT (const std::tm *timeStruct, std::time_t *ret)
 

Variables

static const std::chrono::milliseconds GRACE_PERIOD {500}
 Grace period used to avoid restarting the internal thread too often. More...
 
static const int ENCODED_TIME_STRING_YEAR_STRING_LENGTH = 4
 The length of the year element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_MONTH_STRING_LENGTH = 2
 The length of the month element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_DAY_STRING_LENGTH = 2
 The length of the day element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_HOUR_STRING_LENGTH = 2
 The length of the hour element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_MINUTE_STRING_LENGTH = 2
 The length of the minute element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_SECOND_STRING_LENGTH = 2
 The length of the second element in an ISO-8601 formatted string. More...
 
static const int ENCODED_TIME_STRING_POSTFIX_STRING_LENGTH = 4
 The length of the post-fix element in an ISO-8601 formatted string. More...
 
static const std::string ENCODED_TIME_STRING_DASH_SEPARATOR_STRING = "-"
 The dash separator used in an ISO-8601 formatted string. More...
 
static const std::string ENCODED_TIME_STRING_T_SEPARATOR_STRING = "T"
 The 'T' separator used in an ISO-8601 formatted string. More...
 
static const std::string ENCODED_TIME_STRING_COLON_SEPARATOR_STRING = ":"
 The colon separator used in an ISO-8601 formatted string. More...
 
static const std::string ENCODED_TIME_STRING_PLUS_SEPARATOR_STRING = "+"
 The plus separator used in an ISO-8601 formatted string. More...
 
static const unsigned long ENCODED_TIME_STRING_YEAR_OFFSET = 0
 The offset into an ISO-8601 formatted string where the year begins. More...
 
static const unsigned long ENCODED_TIME_STRING_MONTH_OFFSET
 The offset into an ISO-8601 formatted string where the month begins. More...
 
static const unsigned long ENCODED_TIME_STRING_DAY_OFFSET
 The offset into an ISO-8601 formatted string where the day begins. More...
 
static const unsigned long ENCODED_TIME_STRING_HOUR_OFFSET
 The offset into an ISO-8601 formatted string where the hour begins. More...
 
static const unsigned long ENCODED_TIME_STRING_MINUTE_OFFSET
 The offset into an ISO-8601 formatted string where the minute begins. More...
 
static const unsigned long ENCODED_TIME_STRING_SECOND_OFFSET
 The offset into an ISO-8601 formatted string where the second begins. More...
 
static const unsigned long ENCODED_TIME_STRING_EXPECTED_LENGTH
 The total expected length of an ISO-8601 formatted string. More...
 

Function Documentation

◆ convertToLocalTimeT()

static bool alexaClientSDK::avsCommon::utils::timing::convertToLocalTimeT ( const std::tm *  timeStruct,
std::time_t *  ret 
)
static

Utility function that wraps localtime conversion to std::time_t.

This function also creates a copy of the given timeStruct since mktime can change the object. Note that the tm_isdst is set to -1 as we leave it to std::mktime to determine if daylight savings is in effect.

Parameters
timeStructRequired pointer to timeStruct to be converted to time_t.
[out]retRequired pointer to object where the result will be saved.
Returns
Whether the conversion was successful.

◆ elapsed()

static std::chrono::milliseconds alexaClientSDK::avsCommon::utils::timing::elapsed ( std::chrono::steady_clock::time_point  later,
std::chrono::steady_clock::time_point  earlier 
)
static

Helper method to get the elapsed time in milliseconds from two time_point values.

Parameters
laterThe end time for the calculation .
earlierThe start time for the calculation.
Returns
The elapsed time in milliseconds from two time_point values.

◆ getDistantFuture()

std::chrono::steady_clock::time_point alexaClientSDK::avsCommon::utils::timing::getDistantFuture ( )
inline

Get a consistent future steady_clock::time_point that we deem unreachable (110+ years), avoiding steady_clock::time_point::max() which results in an overflow due to a gcc bug.

See also
https://gcc-bugs.gcc.gnu.narkive.com/LBRgUQhD/bug-c-58931-new-condition-variable-wait-until-overflowed-by-large-time-point-steady-clock
Returns
Get a consistent steady_clock::time_point that we deem unreachable.

◆ TAG() [1/5]

static const std::string alexaClientSDK::avsCommon::utils::timing::TAG ( "Stopwatch"  )
static

String to identify log entries originating from this file.

◆ TAG() [2/5]

static const std::string alexaClientSDK::avsCommon::utils::timing::TAG ( Timer::getTag()  )
static

String to identify log entries originating from this file.

◆ TAG() [3/5]

static const std::string alexaClientSDK::avsCommon::utils::timing::TAG ( "MultiTimer"  )
static

String to identify log entries originating from this file.

◆ TAG() [4/5]

static const std::string alexaClientSDK::avsCommon::utils::timing::TAG ( "TimePoint"  )
static

String to identify log entries originating from this file.

◆ TAG() [5/5]

static const std::string alexaClientSDK::avsCommon::utils::timing::TAG ( "TimeUtils"  )
static

String to identify log entries originating from this file.

Variable Documentation

◆ ENCODED_TIME_STRING_COLON_SEPARATOR_STRING

const std::string alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_COLON_SEPARATOR_STRING = ":"
static

The colon separator used in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_DASH_SEPARATOR_STRING

const std::string alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_DASH_SEPARATOR_STRING = "-"
static

The dash separator used in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_DAY_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_DAY_OFFSET
static
Initial value:
static const std::string ENCODED_TIME_STRING_DASH_SEPARATOR_STRING
The dash separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:60
static const int ENCODED_TIME_STRING_MONTH_STRING_LENGTH
The length of the month element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:48
static const unsigned long ENCODED_TIME_STRING_MONTH_OFFSET
The offset into an ISO-8601 formatted string where the month begins.
Definition: TimeUtils.cpp:71

The offset into an ISO-8601 formatted string where the day begins.

◆ ENCODED_TIME_STRING_DAY_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_DAY_STRING_LENGTH = 2
static

The length of the day element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_EXPECTED_LENGTH

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_EXPECTED_LENGTH
static
Initial value:
=
static const int ENCODED_TIME_STRING_SECOND_STRING_LENGTH
The length of the second element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:56
static const int ENCODED_TIME_STRING_POSTFIX_STRING_LENGTH
The length of the post-fix element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:58
static const std::string ENCODED_TIME_STRING_PLUS_SEPARATOR_STRING
The plus separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:66
static const unsigned long ENCODED_TIME_STRING_SECOND_OFFSET
The offset into an ISO-8601 formatted string where the second begins.
Definition: TimeUtils.cpp:87

The total expected length of an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_HOUR_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_HOUR_OFFSET
static
Initial value:
static const int ENCODED_TIME_STRING_DAY_STRING_LENGTH
The length of the day element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:50
static const unsigned long ENCODED_TIME_STRING_DAY_OFFSET
The offset into an ISO-8601 formatted string where the day begins.
Definition: TimeUtils.cpp:75
static const std::string ENCODED_TIME_STRING_T_SEPARATOR_STRING
The 'T' separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:62

The offset into an ISO-8601 formatted string where the hour begins.

◆ ENCODED_TIME_STRING_HOUR_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_HOUR_STRING_LENGTH = 2
static

The length of the hour element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_MINUTE_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_MINUTE_OFFSET
static
Initial value:
static const int ENCODED_TIME_STRING_HOUR_STRING_LENGTH
The length of the hour element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:52
static const std::string ENCODED_TIME_STRING_COLON_SEPARATOR_STRING
The colon separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:64
static const unsigned long ENCODED_TIME_STRING_HOUR_OFFSET
The offset into an ISO-8601 formatted string where the hour begins.
Definition: TimeUtils.cpp:79

The offset into an ISO-8601 formatted string where the minute begins.

◆ ENCODED_TIME_STRING_MINUTE_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_MINUTE_STRING_LENGTH = 2
static

The length of the minute element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_MONTH_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_MONTH_OFFSET
static
Initial value:
static const std::string ENCODED_TIME_STRING_DASH_SEPARATOR_STRING
The dash separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:60
static const int ENCODED_TIME_STRING_YEAR_STRING_LENGTH
The length of the year element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:46
static const unsigned long ENCODED_TIME_STRING_YEAR_OFFSET
The offset into an ISO-8601 formatted string where the year begins.
Definition: TimeUtils.cpp:69

The offset into an ISO-8601 formatted string where the month begins.

◆ ENCODED_TIME_STRING_MONTH_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_MONTH_STRING_LENGTH = 2
static

The length of the month element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_PLUS_SEPARATOR_STRING

const std::string alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_PLUS_SEPARATOR_STRING = "+"
static

The plus separator used in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_POSTFIX_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_POSTFIX_STRING_LENGTH = 4
static

The length of the post-fix element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_SECOND_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_SECOND_OFFSET
static
Initial value:
static const unsigned long ENCODED_TIME_STRING_MINUTE_OFFSET
The offset into an ISO-8601 formatted string where the minute begins.
Definition: TimeUtils.cpp:83
static const std::string ENCODED_TIME_STRING_COLON_SEPARATOR_STRING
The colon separator used in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:64
static const int ENCODED_TIME_STRING_MINUTE_STRING_LENGTH
The length of the minute element in an ISO-8601 formatted string.
Definition: TimeUtils.cpp:54

The offset into an ISO-8601 formatted string where the second begins.

◆ ENCODED_TIME_STRING_SECOND_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_SECOND_STRING_LENGTH = 2
static

The length of the second element in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_T_SEPARATOR_STRING

const std::string alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_T_SEPARATOR_STRING = "T"
static

The 'T' separator used in an ISO-8601 formatted string.

◆ ENCODED_TIME_STRING_YEAR_OFFSET

const unsigned long alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_YEAR_OFFSET = 0
static

The offset into an ISO-8601 formatted string where the year begins.

◆ ENCODED_TIME_STRING_YEAR_STRING_LENGTH

const int alexaClientSDK::avsCommon::utils::timing::ENCODED_TIME_STRING_YEAR_STRING_LENGTH = 4
static

The length of the year element in an ISO-8601 formatted string.

◆ GRACE_PERIOD

const std::chrono::milliseconds alexaClientSDK::avsCommon::utils::timing::GRACE_PERIOD {500}
static

Grace period used to avoid restarting the internal thread too often.

AlexaClientSDK 1.26.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0