File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class DMDUTILAPI DMDServer
2222
2323 bool Start (const char * addr, in_port_t port);
2424 void Stop ();
25- bool IsRunning () const { return m_running; }
25+ bool IsRunning () const { return m_running. load (std::memory_order_acquire) ; }
2626
2727 private:
2828 void AcceptLoop ();
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ DMDServer::~DMDServer() { Stop(); }
2727
2828bool DMDServer::Start (const char * addr, in_port_t port)
2929{
30- if (m_running) return false ;
30+ if (m_running. load (std::memory_order_acquire) || !m_dmd-> HasDisplay () ) return false ;
3131
3232 sockpp::initialize ();
3333 m_acceptor = sockpp::tcp_acceptor ({addr, port});
@@ -37,14 +37,14 @@ bool DMDServer::Start(const char* addr, in_port_t port)
3737 return false ;
3838 }
3939
40- m_running = true ;
40+ m_running. store ( true , std::memory_order_release) ;
4141 m_acceptThread = new std::thread (&DMDServer::AcceptLoop, this );
4242 return true ;
4343}
4444
4545void DMDServer::Stop ()
4646{
47- m_running = false ;
47+ m_running. store ( false , std::memory_order_release) ;
4848
4949 if (m_acceptThread)
5050 {
@@ -62,7 +62,9 @@ void DMDServer::AcceptLoop()
6262{
6363 uint32_t threadId = 0 ;
6464
65- while (m_running && m_dmd->HasDisplay ())
65+ (void )m_running.load (std::memory_order_acquire);
66+
67+ while (m_running.load (std::memory_order_relaxed))
6668 {
6769 sockpp::inet_address peer;
6870 sockpp::tcp_socket sock = m_acceptor.accept (&peer);
You can’t perform that action at this time.
0 commit comments