本文整理汇总了C++中common::BlockingLoop::Prepare方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockingLoop::Prepare方法的具体用法?C++ BlockingLoop::Prepare怎么用?C++ BlockingLoop::Prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::BlockingLoop
的用法示例。
在下文中一共展示了BlockingLoop::Prepare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop_thread
TEST(BusyLoopTest, MultiThreaded)
{
Common::BlockingLoop loop;
Common::Event e;
for (int i = 0; i < 100; i++)
{
loop.Prepare();
std::thread loop_thread([&]() { loop.Run([&]() { e.Set(); }); });
// Ping - Pong
for (int j = 0; j < 10; j++)
{
loop.Wakeup();
e.Wait();
// Just waste some time. So the main loop did fall back to the sleep state much more likely.
Common::SleepCurrentThread(1);
}
for (int j = 0; j < 100; j++)
{
// We normally have to call Wakeup to assure the Event is triggered.
// But this check is for an internal feature of the BlockingLoop.
// It's implemented to fall back to a busy loop regulary.
// If we're in the busy loop, the payload (and so the Event) is called all the time.
// loop.Wakeup();
e.Wait();
}
loop.Stop();
loop_thread.join();
}
}
示例2: Fifo_Init
void Fifo_Init()
{
// Padded so that SIMD overreads in the vertex loader are safe
s_video_buffer = (u8*)AllocateMemoryPages(FIFO_SIZE + 4);
ResetVideoBuffer();
if (SConfig::GetInstance().bCPUThread)
s_gpu_mainloop.Prepare();
s_sync_ticks.store(0);
}