SObjectizer 5.8
Loading...
Searching...
No Matches
so_5::details::remaining_time_counter_t Class Reference

Helper class for calculating remaining time. More...

#include <remaining_time_counter.hpp>

Public Member Functions

 remaining_time_counter_t (duration remaining)
 
void update ()
 
duration remaining () const
 
 operator bool () const
 

Private Types

using time_point = std::chrono::steady_clock::time_point
 
using duration = std::chrono::steady_clock::duration
 

Private Attributes

time_point m_last_time
 
duration m_remaining
 

Detailed Description

Helper class for calculating remaining time.

Usage example:

so_5::details::remaining_time_counter_t time_counter{ wait_time };
do
{
some_task( time_counter.remaining() );
time_counter.update();
}
while( time_counter );
Helper class for calculating remaining time.
Since
v.5.5.16

Definition at line 38 of file remaining_time_counter.hpp.

Member Typedef Documentation

◆ duration

using so_5::details::remaining_time_counter_t::duration = std::chrono::steady_clock::duration
private

Definition at line 41 of file remaining_time_counter.hpp.

◆ time_point

using so_5::details::remaining_time_counter_t::time_point = std::chrono::steady_clock::time_point
private

Definition at line 40 of file remaining_time_counter.hpp.

Constructor & Destructor Documentation

◆ remaining_time_counter_t()

so_5::details::remaining_time_counter_t::remaining_time_counter_t ( duration remaining)
inline

Definition at line 63 of file remaining_time_counter.hpp.

Member Function Documentation

◆ operator bool()

so_5::details::remaining_time_counter_t::operator bool ( ) const
inline
Returns
true if m_remaining is greater than duration::zero().

Definition at line 87 of file remaining_time_counter.hpp.

◆ remaining()

duration so_5::details::remaining_time_counter_t::remaining ( ) const
inline

Definition at line 82 of file remaining_time_counter.hpp.

◆ update()

void so_5::details::remaining_time_counter_t::update ( )
inline

Definition at line 69 of file remaining_time_counter.hpp.

Member Data Documentation

◆ m_last_time

time_point so_5::details::remaining_time_counter_t::m_last_time
private
Note
This member in not declared as const to allow reassignment for remaining_time_counter_t object. Like in such cases:
remaining_time_counter_t counter{ some_initial_value };
do
{
do_something();
if( needs_restart )
counter = remaining_time_counter_t{ some_initial_value };
else
counter.update();
}
while( counter );

Definition at line 59 of file remaining_time_counter.hpp.

◆ m_remaining

duration so_5::details::remaining_time_counter_t::m_remaining
private

Definition at line 60 of file remaining_time_counter.hpp.


The documentation for this class was generated from the following file: