Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
class CEndTime

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

Classes

class  kodi::tools::CEndTime
 

Functions

 kodi::tools::CEndTime::CEndTime ()=default
 Class constructor with no time to expiry set.
 
 kodi::tools::CEndTime::CEndTime (unsigned int millisecondsIntoTheFuture)
 Class constructor to set future time when timer has expired.
 
void kodi::tools::CEndTime::Set (unsigned int millisecondsIntoTheFuture)
 Set the time in the future we cosider this timer as expired.
 
bool kodi::tools::CEndTime::IsTimePast () const
 Check if the expiry time has been reached.
 
unsigned int kodi::tools::CEndTime::MillisLeft () const
 The amount of time left till this timer expires.
 
void kodi::tools::CEndTime::SetExpired ()
 Consider this timer expired.
 
void kodi::tools::CEndTime::SetInfinite ()
 Set this timer as never expiring.
 
bool kodi::tools::CEndTime::IsInfinite (void) const
 Check if the timer has been set to infinite expiry.
 
unsigned int kodi::tools::CEndTime::GetInitialTimeoutValue (void) const
 Get the initial timeout value this timer had.
 
uint64_t kodi::tools::CEndTime::GetStartTime (void) const
 Get the time this timer started.
 

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:

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));
}
}
};
#define ATTR_DLL_LOCAL
Definition addon_base.h:86

Function Documentation

◆ CEndTime() [1/2]

kodi::tools::CEndTime::CEndTime ( )
inlinedefault

Class constructor with no time to expiry set.

◆ CEndTime() [2/2]

kodi::tools::CEndTime::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

◆ GetInitialTimeoutValue()

unsigned int kodi::tools::CEndTime::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 kodi::tools::CEndTime::GetStartTime ( void ) const
inline

Get the time this timer started.

Returns
The time this timer started in milliseconds since epoch

◆ IsInfinite()

bool kodi::tools::CEndTime::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

◆ IsTimePast()

bool kodi::tools::CEndTime::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 kodi::tools::CEndTime::MillisLeft ( ) const
inline

The amount of time left till this timer expires.

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

◆ Set()

void kodi::tools::CEndTime::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

◆ SetExpired()

void kodi::tools::CEndTime::SetExpired ( )
inline

Consider this timer expired.

◆ SetInfinite()

void kodi::tools::CEndTime::SetInfinite ( )
inline

Set this timer as never expiring.