26 m_frame_start_time = clock_type::now();
32 m_frame_end_time = clock_type::now();
33 m_frame_duration = m_frame_end_time - m_frame_start_time;
36 if (m_frame_duration < m_min_frame_duration)
39 const time_point_type idle_time = m_frame_end_time + m_min_frame_duration - m_frame_duration;
44 std::this_thread::yield();
45 m_frame_end_time = clock_type::now();
47 while (m_frame_end_time < idle_time);
50 m_frame_duration = m_frame_end_time - m_frame_start_time;
54 m_accumulated_time += std::min<duration_type>(m_max_frame_duration, m_frame_duration);
57 m_frame_start_time = m_frame_end_time;
60 while (m_accumulated_time >= m_fixed_update_interval)
62 m_fixed_update_callback(m_fixed_update_time, m_fixed_update_interval);
64 m_fixed_update_time += m_fixed_update_interval;
65 m_accumulated_time -= m_fixed_update_interval;
69 m_variable_update_callback(m_fixed_update_time, m_fixed_update_interval, m_accumulated_time);
74 m_accumulated_time = duration_type::zero();
75 m_frame_duration = duration_type::zero();
76 m_frame_start_time = clock_type::now();
81 m_fixed_update_time = duration_type::zero();
clock_type::time_point time_point_type
Time point type matches the clock's time point type.
void reset() noexcept
Resets the elapsed fixed-rate update time (t), accumulated time (at), and frame timer.
void refresh() noexcept
Resets the accumulated time (at) and frame timer, but not the elapsed fixed-rate update time.
frame_scheduler() noexcept
Constructs a frame scheduler and starts its frame timer.
void tick()
Performs any scheduled fixed-rate updates followed by a single variable-rate update.