diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2016-06-24 10:43:46 +0200 |
| commit | 3570c7f03a2aa90aa634f96c0af1969af610f14d (patch) | |
| tree | 4252e03c0e853ba7cffe022937698c854ad0eaa9 /Source/UnitTests/Common/BusyLoopTest.cpp | |
| parent | 2115e8a4a6814e32107b5205ff5c95bbd3c6e99c (diff) | |
Reformat all the things. Have fun with merge conflicts.
Diffstat (limited to 'Source/UnitTests/Common/BusyLoopTest.cpp')
| -rw-r--r-- | Source/UnitTests/Common/BusyLoopTest.cpp | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/Source/UnitTests/Common/BusyLoopTest.cpp b/Source/UnitTests/Common/BusyLoopTest.cpp index 50d11acb31..efa13fec6c 100644 --- a/Source/UnitTests/Common/BusyLoopTest.cpp +++ b/Source/UnitTests/Common/BusyLoopTest.cpp @@ -12,40 +12,34 @@ 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(); - } + 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(); + } } |
