MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ wait_for_next_frame()

void MayaFlux::Vruta::FrameClock::wait_for_next_frame ( )

Wait (sleep) until next frame should occur.

Blocks calling thread until next frame time based on target FPS. Uses high-precision sleep for accurate frame pacing.

Called from graphics thread loop after rendering to maintain consistent frame rate.

Definition at line 178 of file Clock.cpp.

179{
180 auto sleep_duration = time_until_next_frame();
181 if (sleep_duration > std::chrono::microseconds(100)) {
182 std::this_thread::sleep_until(m_next_frame_time);
183
184 } else if (sleep_duration > std::chrono::nanoseconds(0)) {
185 auto wake_time = std::chrono::steady_clock::now() + sleep_duration;
186
187 while (std::chrono::steady_clock::now() < wake_time) {
188 std::this_thread::yield();
189 }
190 }
191}
std::chrono::steady_clock::time_point m_next_frame_time
Definition Clock.hpp:284
std::chrono::nanoseconds time_until_next_frame() const
Get time until next frame should occur.
Definition Clock.cpp:90

References m_next_frame_time, and time_until_next_frame().

+ Here is the call graph for this function: