[client] common: added spin timeout to framebuffer wait

This commit is contained in:
Geoffrey McRae 2020-10-30 03:27:28 +11:00
parent c8f740c34e
commit 6799d518a5

View File

@ -39,9 +39,14 @@ const size_t FrameBufferStructSize = sizeof(FrameBuffer);
void framebuffer_wait(const FrameBuffer * frame, size_t size)
{
while(atomic_load_explicit(&frame->wp, memory_order_acquire) < size) {
while(atomic_load_explicit(&frame->wp, memory_order_acquire) < size)
{
int spinCount = 0;
while(frame->wp < size)
{
if (++spinCount == FB_SPIN_LIMIT)
return;
usleep(1);
}
}
}