Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
class CEndTime

Detailed Description

Timeout check
Class which makes it easy to check if a specified amount of time has passed.

This code uses the support of platform-independent chrono system introduced with C++11.


Example:

#include <kodi/tools/EndTime.h>
class ATTR_DLL_LOCAL CExample
{
public:
CExample()
{
TimerCall();
}
void TimerCall()
{
fprintf(stderr, "Hello World\n");
CEndTime timer(1000);
while (timer.MillisLeft())
{
if (timer.IsTimePast())
{
fprintf(stderr, "We timed out!\n");
}
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
};

Function Documentation

◆ CEndTime() [1/2]

CEndTime ( )
inlinedefault

Class constructor with no time to expiry set.

◆ CEndTime() [2/2]

CEndTime ( unsigned int millisecondsIntoTheFuture)
inlineexplicit

Class constructor to set future time when timer has expired.

Parameters
[in]millisecondsIntoTheFuturethe time in the future we cosider this timer as expired

◆ Set()

void Set ( unsigned int millisecondsIntoTheFuture)
inline

Set the time in the future we cosider this timer as expired.

Parameters
[in]millisecondsIntoTheFuturethe time in the future we cosider this timer as expired

◆ IsTimePast()

bool IsTimePast ( ) const
inline

Check if the expiry time has been reached.

Returns
True if the expiry amount of time has past, false otherwise

◆ MillisLeft()

unsigned int MillisLeft ( ) const
inline

The amount of time left till this timer expires.

Returns
0 if the expiry amount of time has past, the numbe rof milliseconds remaining otherwise

◆ SetExpired()

void SetExpired ( )
inline

Consider this timer expired.

◆ SetInfinite()

void SetInfinite ( )
inline

Set this timer as never expiring.

◆ IsInfinite()

bool IsInfinite ( void ) const
inline

Check if the timer has been set to infinite expiry.

Returns
True if the expiry has been set as infinite, false otherwise

◆ GetInitialTimeoutValue()

unsigned int GetInitialTimeoutValue ( void ) const
inline

Get the initial timeout value this timer had.

Returns
The initial expiry amount of time this timer had in milliseconds

◆ GetStartTime()

uint64_t GetStartTime ( void ) const
inline

Get the time this timer started.

Returns
The time this timer started in milliseconds since epoch