![]()  | 
  
    General Utility Library for C++17 25.7.0
    
   | 
 
Time-related functions.
Functions | |
| std::chrono::steady_clock::time_point | gul17::tic () | 
| Return the current time as a std::chrono time_point.   | |
| template<class TimeUnitType = std::chrono::duration<double>> | |
| auto | gul17::toc (std::chrono::steady_clock::time_point t0) | 
| Return the elapsed time in seconds (or a different unit) since the given time point.   | |
| template<class Rep , class Period > | |
| bool | gul17::sleep (const std::chrono::duration< Rep, Period > &duration, const Trigger &trg) | 
| Sleep for at least the given time span, with the option of being woken up from another thread.   | |
| bool | gul17::sleep (double seconds, const Trigger &trg) | 
| Sleep for a given number of seconds, with the option of being woken up from another thread.   | |
| template<class Rep , class Period > | |
| bool | gul17::sleep (const std::chrono::duration< Rep, Period > &duration) | 
| Sleep for a given time span.   | |
| bool | gul17::sleep (double seconds) | 
| Sleep for a given number of seconds.   | |
Sleep for a given time span.
This is equivalent to a call of std::this_thread::sleep_for(), which means that control is handed back to the operating system's task scheduler. This may result in a somewhat bigger effective delay than expected, especially where very small sleep times are requested and the system load is high.
Example:
| duration | Time span to wait, as a std::chrono::duration type. | 
References gul17::bit_set().
Sleep for at least the given time span, with the option of being woken up from another thread.
The sleep can be interrupted from another thread via a shared Trigger object.
Calling sleep() may lead to a context switch of the operation system. Under heavy load or resource contention, this can produce a delay that is longer than expected.
| duration | Time span to wait, as a std::chrono::duration type. | 
| trg | Reference to a SleepInterrupt object that can be used to interrupt the delay. If such an interruption occurs, false is returned. | 
References gul17::bit_set().
Referenced by gul17::sleep(), and gul17::sleep().
Sleep for a given number of seconds.
This is equivalent to a call of std::this_thread::sleep_for(), which means that control is handed back to the operating system's task scheduler. This may result in a somewhat bigger effective delay than expected, especially where very small sleep times are requested and the system load is high.
Example:
| seconds | Seconds to wait. | 
References gul17::bit_set(), and gul17::sleep().
Sleep for a given number of seconds, with the option of being woken up from another thread.
The sleep can be interrupted from another thread via a shared Trigger object.
Calling sleep() may lead to a context switch of the operation system. Under heavy load or resource contention, this can produce a delay that is longer than expected.
| seconds | Seconds to wait. | 
| trg | Reference to a SleepInterrupt object that can be used to interrupt the delay. If such an interruption occurs, false is returned. | 
References gul17::bit_set(), and gul17::sleep().
      
  | 
  inline | 
Return the current time as a std::chrono time_point.
This function is intended to be used with the sister function toc() to measure elapsed time.
Referenced by gul17::toc().
| auto gul17::toc | ( | std::chrono::steady_clock::time_point | t0 | ) | 
Return the elapsed time in seconds (or a different unit) since the given time point.
This function is intended to be used with the sister function tic() to measure elapsed time. toc() is a function template that returns the elapsed seconds as a double value by default; by specifying a different chrono type as a template parameter, it can also return other time units and other types.
| TimeUnitType | The type to be used for calculating the elapsed time since t0. By default, this is std::chrono::duration<double>, which means that the elapsed time is returned as a double that represents seconds. | 
| t0 | A time point in the past that should be taken with tic(). | 
References gul17::bit_set(), and gul17::tic().