feat(video2x): improved the timer

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
k4yt3x
2024-11-03 00:00:00 +00:00
parent d6f27b3f22
commit fbe3b44139
4 changed files with 122 additions and 17 deletions

View File

@@ -0,0 +1,34 @@
#ifndef TIMER_H
#define TIMER_H
#include <atomic>
#include <chrono>
#include <cstdint>
#include <thread>
class Timer {
public:
Timer();
~Timer();
void start();
void pause();
void resume();
void stop();
bool is_running() const;
bool is_paused() const;
int64_t get_elapsed_time() const;
private:
std::atomic<bool> running;
std::atomic<bool> paused;
std::thread timer_thread;
int64_t elapsed_time;
std::chrono::steady_clock::time_point start_time;
std::chrono::steady_clock::time_point pause_start_time;
void update_elapsed_time();
};
#endif // TIMER_H