Skip to content

Commit

Permalink
broker: using atomic_flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsanches committed Aug 20, 2024
1 parent eda9940 commit 1d84651
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Broker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// defined by the Mozilla Public License, v. 2.0.


#include <atomic>
#include <chrono>

#include <Clock.h>
Expand All @@ -27,7 +28,7 @@

constexpr auto BUILD_NUM = DCCLITE_VERSION;

static bool g_fExitRequested = false;
static std::atomic_flag g_fExitRequested;

class NullEventTarget: public dcclite::broker::EventHub::IEventTarget
{
Expand All @@ -52,7 +53,7 @@ class QuitEvent: public dcclite::broker::EventHub::IEvent

static bool ConsoleCtrlHandler(dcclite::ConsoleEvent event)
{
g_fExitRequested = true;
g_fExitRequested.test_and_set(std::memory_order_relaxed);

static NullEventTarget g_NullTarget;

Expand Down Expand Up @@ -93,7 +94,7 @@ int main(int argc, char **argv)
unsigned frameCount = 0;
auto startTime = dcclite::Clock::DefaultClock_t::now();

while (!g_fExitRequested)
while (!g_fExitRequested.test(std::memory_order_relaxed))
{
auto now = dcclite::Clock::DefaultClock_t::now();

Expand Down

0 comments on commit 1d84651

Please sign in to comment.