mirror of
https://github.com/k4yt3x/video2x.git
synced 2024-12-29 16:09:10 +00:00
35 lines
628 B
C
35 lines
628 B
C
|
#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
|