Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
sleep_scheduler.h
Go to the documentation of this file.
1#ifndef SLEEP_SCHEDULER_H
2#define SLEEP_SCHEDULER_H
3
4#include "fps_clock.h"
5
8{
9public:
10
12 double get_fps() const noexcept { return m_fps_clock.get_fps(); }
13
15 void set_target_fps(double fps);
16
20 void tick();
21
22private:
23
25 fps_clock m_fps_clock;
26
28 double m_sleep_time_microseconds{1.0};
29
31 double m_target_fps{60.0};
32};
33
36
37#endif // SLEEP_SCHEDULER_H
Clock to count the frames per second.
Definition fps_clock.h:9
double get_fps() const noexcept
Get the frames per seconds.
Definition fps_clock.h:14
Sleeps enough to reach 50-60 frames per second.
Definition sleep_scheduler.h:8
double get_fps() const noexcept
Get the number of frames per second.
Definition sleep_scheduler.h:12
void tick()
Indicate a frame has passed.
Definition sleep_scheduler.cpp:11
void set_target_fps(double fps)
Sets the target frame rate.
Definition sleep_scheduler.cpp:5
void test_sleep_scheduler()
Test this class.
Definition sleep_scheduler.cpp:27