MayaFlux 0.1.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 177 of file Clock.cpp.

178{
179 auto sleep_duration = time_until_next_frame();
180 if (sleep_duration > std::chrono::microseconds(100)) {
181 std::this_thread::sleep_until(m_next_frame_time);
182
183 } else if (sleep_duration > std::chrono::nanoseconds(0)) {
184 auto wake_time = std::chrono::steady_clock::now() + sleep_duration;
185
186 while (std::chrono::steady_clock::now() < wake_time) {
187 std::this_thread::yield();
188 }
189 }
190}
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:89

References m_next_frame_time, and time_until_next_frame().

+ Here is the call graph for this function: