m_bStopThread -> keep_running

pull/1/head
Tom Early 6 years ago
parent ef252ec37a
commit e5f734266e

@ -36,7 +36,7 @@
CCodecStream::CCodecStream(uint16 uiId, uint8 uiCodecIn, uint8 uiCodecOut) CCodecStream::CCodecStream(uint16 uiId, uint8 uiCodecIn, uint8 uiCodecOut)
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
m_uiStreamId = uiId; m_uiStreamId = uiId;
m_uiPid = 0; m_uiPid = 0;
@ -61,7 +61,7 @@ CCodecStream::~CCodecStream()
m_Socket.Close(); m_Socket.Close();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -77,7 +77,7 @@ bool CCodecStream::Init(uint16 uiPort)
bool ok; bool ok;
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// copy our test data // copy our test data
if ( m_uiCodecIn == CODEC_AMBE2PLUS ) if ( m_uiCodecIn == CODEC_AMBE2PLUS )
@ -141,7 +141,7 @@ void CCodecStream::Close(void)
m_Socket.Close(); m_Socket.Close();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -156,7 +156,7 @@ void CCodecStream::Close(void)
void CCodecStream::Thread(CCodecStream *This) void CCodecStream::Thread(CCodecStream *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->Task(); This->Task();
} }

@ -95,7 +95,7 @@ protected:
bool m_bConnected; bool m_bConnected;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
CTimePoint m_TimeoutTimer; CTimePoint m_TimeoutTimer;
CTimePoint m_FrameTimer; CTimePoint m_FrameTimer;

@ -45,7 +45,7 @@ CTranscoder g_Transcoder;
CTranscoder::CTranscoder() CTranscoder::CTranscoder()
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
m_Streams.reserve(12); m_Streams.reserve(12);
m_bConnected = false; m_bConnected = false;
@ -74,7 +74,7 @@ CTranscoder::~CTranscoder()
m_Mutex.unlock(); m_Mutex.unlock();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -90,7 +90,7 @@ bool CTranscoder::Init(const CIp &ListenIp, const CIp &AmbedIp)
bool ok; bool ok;
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// create server's IP // create server's IP
m_ListenIp = ListenIp; m_ListenIp = ListenIp;
@ -130,7 +130,7 @@ void CTranscoder::Close(void)
m_Mutex.unlock(); m_Mutex.unlock();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -144,7 +144,7 @@ void CTranscoder::Close(void)
void CTranscoder::Thread(CTranscoder *This) void CTranscoder::Thread(CTranscoder *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->Task(); This->Task();
} }
@ -385,4 +385,3 @@ void CTranscoder::EncodeClosestreamPacket(CBuffer *Buffer, uint16 uiStreamId)
Buffer->Set(tag, sizeof(tag)); Buffer->Set(tag, sizeof(tag));
Buffer->Append((uint16)uiStreamId); Buffer->Append((uint16)uiStreamId);
} }

@ -96,7 +96,7 @@ protected:
uint16 m_PortOpenStream; uint16 m_PortOpenStream;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
// socket // socket

@ -38,7 +38,7 @@
CCodecStream::CCodecStream(CPacketStream *PacketStream, uint16 uiId, uint8 uiCodecIn, uint8 uiCodecOut) CCodecStream::CCodecStream(CPacketStream *PacketStream, uint16 uiId, uint8 uiCodecIn, uint8 uiCodecOut)
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
m_uiStreamId = uiId; m_uiStreamId = uiId;
m_uiPid = 0; m_uiPid = 0;
@ -63,7 +63,7 @@ CCodecStream::~CCodecStream()
m_Socket.Close(); m_Socket.Close();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -90,7 +90,7 @@ CCodecStream::~CCodecStream()
bool CCodecStream::Init(uint16 uiPort) bool CCodecStream::Init(uint16 uiPort)
{ {
// reset stop flag // reset stop flag
m_bConnected = m_bStopThread = false; m_bConnected = keep_running = true;
// create server's IP // create server's IP
m_uiPort = uiPort; m_uiPort = uiPort;
@ -124,7 +124,7 @@ void CCodecStream::Close(void)
m_Socket.Close(); m_Socket.Close();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -146,7 +146,7 @@ bool CCodecStream::IsEmpty(void) const
void CCodecStream::Thread(CCodecStream *This) void CCodecStream::Thread(CCodecStream *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->Task(); This->Task();
} }

@ -97,7 +97,7 @@ protected:
CPacketQueue m_LocalQueue; CPacketQueue m_LocalQueue;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
CTimePoint m_TimeoutTimer; CTimePoint m_TimeoutTimer;
CTimePoint m_StatsTimer; CTimePoint m_StatsTimer;

@ -34,14 +34,14 @@
CDmridDir::CDmridDir() CDmridDir::CDmridDir()
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
} }
CDmridDir::~CDmridDir() CDmridDir::~CDmridDir()
{ {
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -59,7 +59,7 @@ bool CDmridDir::Init(void)
Reload(); Reload();
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// start thread; // start thread;
m_pThread = new std::thread(CDmridDir::Thread, this); m_pThread = new std::thread(CDmridDir::Thread, this);
@ -69,7 +69,7 @@ bool CDmridDir::Init(void)
void CDmridDir::Close(void) void CDmridDir::Close(void)
{ {
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -83,7 +83,7 @@ void CDmridDir::Close(void)
void CDmridDir::Thread(CDmridDir *This) void CDmridDir::Thread(CDmridDir *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
// Wait 30 seconds // Wait 30 seconds
CTimePoint::TaskSleepFor(DMRIDDB_REFRESH_RATE * 60000); CTimePoint::TaskSleepFor(DMRIDDB_REFRESH_RATE * 60000);
@ -157,4 +157,3 @@ bool CDmridDir::IsValidDmrid(const char *sz)
} }
return ok; return ok;
} }

@ -86,7 +86,7 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
}; };

@ -46,7 +46,7 @@ bool CG3Protocol::Init(void)
m_ReflectorCallsign = g_Reflector.GetCallsign(); m_ReflectorCallsign = g_Reflector.GetCallsign();
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// update the reflector callsign // update the reflector callsign
m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)"XLX", 3); m_ReflectorCallsign.PatchCallsign(0, (const uint8 *)"XLX", 3);
@ -124,7 +124,7 @@ void CG3Protocol::Close(void)
void CG3Protocol::PresenceThread(CG3Protocol *This) void CG3Protocol::PresenceThread(CG3Protocol *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->PresenceTask(); This->PresenceTask();
} }
@ -132,7 +132,7 @@ void CG3Protocol::PresenceThread(CG3Protocol *This)
void CG3Protocol::ConfigThread(CG3Protocol *This) void CG3Protocol::ConfigThread(CG3Protocol *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->ConfigTask(); This->ConfigTask();
} }
@ -140,7 +140,7 @@ void CG3Protocol::ConfigThread(CG3Protocol *This)
void CG3Protocol::IcmpThread(CG3Protocol *This) void CG3Protocol::IcmpThread(CG3Protocol *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->IcmpTask(); This->IcmpTask();
} }

@ -36,7 +36,7 @@ CGateKeeper g_GateKeeper;
CGateKeeper::CGateKeeper() CGateKeeper::CGateKeeper()
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
} }
@ -46,7 +46,7 @@ CGateKeeper::CGateKeeper()
CGateKeeper::~CGateKeeper() CGateKeeper::~CGateKeeper()
{ {
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -67,7 +67,7 @@ bool CGateKeeper::Init(void)
m_PeerList.LoadFromFile(INTERLINKLIST_PATH); m_PeerList.LoadFromFile(INTERLINKLIST_PATH);
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// start thread; // start thread;
m_pThread = new std::thread(CGateKeeper::Thread, this); m_pThread = new std::thread(CGateKeeper::Thread, this);
@ -77,7 +77,7 @@ bool CGateKeeper::Init(void)
void CGateKeeper::Close(void) void CGateKeeper::Close(void)
{ {
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -177,7 +177,7 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int prot
void CGateKeeper::Thread(CGateKeeper *This) void CGateKeeper::Thread(CGateKeeper *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
// Wait 30 seconds // Wait 30 seconds
CTimePoint::TaskSleepFor(30000); CTimePoint::TaskSleepFor(30000);
@ -273,4 +273,3 @@ bool CGateKeeper::IsPeerListedOk(const CCallsign &callsign, const CIp &ip, char
// done // done
return ok; return ok;
} }

@ -71,7 +71,7 @@ protected:
CPeerCallsignList m_PeerList; CPeerCallsignList m_PeerList;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
}; };

@ -33,7 +33,7 @@
// constructor // constructor
CProtocol::CProtocol() : m_bStopThread(false), m_pThread(NULL) {} CProtocol::CProtocol() : keep_running(true), m_pThread(NULL) {}
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -42,7 +42,7 @@ CProtocol::CProtocol() : m_bStopThread(false), m_pThread(NULL) {}
CProtocol::~CProtocol() CProtocol::~CProtocol()
{ {
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -71,7 +71,7 @@ bool CProtocol::Initialize(const char *type, uint16 port)
m_ReflectorCallsign = g_Reflector.GetCallsign(); m_ReflectorCallsign = g_Reflector.GetCallsign();
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// update the reflector callsign // update the reflector callsign
if (type) if (type)
@ -110,7 +110,7 @@ bool CProtocol::Initialize(const char *type, uint16 port)
void CProtocol::Thread(CProtocol *This) void CProtocol::Thread(CProtocol *This)
{ {
while (! This->m_bStopThread) while (This->keep_running)
{ {
This->Task(); This->Task();
} }
@ -118,7 +118,7 @@ void CProtocol::Thread(CProtocol *This)
void CProtocol::Close(void) void CProtocol::Close(void)
{ {
m_bStopThread = true; keep_running = true;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();

@ -137,7 +137,7 @@ protected:
CPacketQueue m_Queue; CPacketQueue m_Queue;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
// identity // identity

@ -38,7 +38,7 @@
CReflector::CReflector() CReflector::CReflector()
{ {
m_bStopThreads = false; keep_running = true;
m_XmlReportThread = NULL; m_XmlReportThread = NULL;
m_JsonReportThread = NULL; m_JsonReportThread = NULL;
for ( int i = 0; i < NB_OF_MODULES; i++ ) for ( int i = 0; i < NB_OF_MODULES; i++ )
@ -55,7 +55,7 @@ CReflector::CReflector(const CCallsign &callsign)
#ifdef DEBUG_DUMPFILE #ifdef DEBUG_DUMPFILE
m_DebugFile.close(); m_DebugFile.close();
#endif #endif
m_bStopThreads = false; keep_running = true;
m_XmlReportThread = NULL; m_XmlReportThread = NULL;
m_JsonReportThread = NULL; m_JsonReportThread = NULL;
for ( int i = 0; i < NB_OF_MODULES; i++ ) for ( int i = 0; i < NB_OF_MODULES; i++ )
@ -70,7 +70,7 @@ CReflector::CReflector(const CCallsign &callsign)
CReflector::~CReflector() CReflector::~CReflector()
{ {
m_bStopThreads = true; keep_running = false;
if ( m_XmlReportThread != NULL ) if ( m_XmlReportThread != NULL )
{ {
m_XmlReportThread->join(); m_XmlReportThread->join();
@ -100,7 +100,7 @@ bool CReflector::Start(void)
bool ok = true; bool ok = true;
// reset stop flag // reset stop flag
m_bStopThreads = false; keep_running = true;
// init gate keeper // init gate keeper
ok &= g_GateKeeper.Init(); ok &= g_GateKeeper.Init();
@ -144,7 +144,7 @@ bool CReflector::Start(void)
void CReflector::Stop(void) void CReflector::Stop(void)
{ {
// stop & delete all threads // stop & delete all threads
m_bStopThreads = true; keep_running = false;
// stop & delete report threads // stop & delete report threads
if ( m_XmlReportThread != NULL ) if ( m_XmlReportThread != NULL )
@ -325,7 +325,7 @@ void CReflector::RouterThread(CReflector *This, CPacketStream *streamIn)
// get on input queue // get on input queue
CPacket *packet; CPacket *packet;
while ( !This->m_bStopThreads ) while (This->keep_running)
{ {
// any packet in our input queue ? // any packet in our input queue ?
streamIn->Lock(); streamIn->Lock();
@ -384,7 +384,7 @@ void CReflector::RouterThread(CReflector *This, CPacketStream *streamIn)
void CReflector::XmlReportThread(CReflector *This) void CReflector::XmlReportThread(CReflector *This)
{ {
while ( !This->m_bStopThreads ) while (This->keep_running)
{ {
// report to xml file // report to xml file
std::ofstream xmlFile; std::ofstream xmlFile;
@ -423,7 +423,7 @@ void CReflector::JsonReportThread(CReflector *This)
if ( Socket.Open(JSON_PORT) ) if ( Socket.Open(JSON_PORT) )
{ {
// and loop // and loop
while ( !This->m_bStopThreads ) while (This->keep_running)
{ {
// any command ? // any command ?
if ( Socket.Receive(Buffer, Ip, 50) ) if ( Socket.Receive(Buffer, Ip, 50) )

@ -136,7 +136,7 @@ protected:
std::array<CPacketStream, NB_OF_MODULES> m_Streams; std::array<CPacketStream, NB_OF_MODULES> m_Streams;
// threads // threads
bool m_bStopThreads; std::atomic<bool> keep_running;
std::array<std::thread *, NB_OF_MODULES> m_RouterThreads; std::array<std::thread *, NB_OF_MODULES> m_RouterThreads;
std::thread *m_XmlReportThread; std::thread *m_XmlReportThread;
std::thread *m_JsonReportThread; std::thread *m_JsonReportThread;

@ -46,7 +46,7 @@ CTranscoder g_Transcoder;
CTranscoder::CTranscoder() CTranscoder::CTranscoder()
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
m_bConnected = false; m_bConnected = false;
m_LastKeepaliveTime.Now(); m_LastKeepaliveTime.Now();
@ -72,7 +72,7 @@ bool CTranscoder::Init(void)
bool ok; bool ok;
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// create server's IP // create server's IP
auto s = g_Reflector.GetTranscoderIp(); auto s = g_Reflector.GetTranscoderIp();
@ -116,7 +116,7 @@ void CTranscoder::Close(void)
m_Mutex.unlock(); m_Mutex.unlock();
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -130,7 +130,7 @@ void CTranscoder::Close(void)
void CTranscoder::Thread(CTranscoder *This) void CTranscoder::Thread(CTranscoder *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->Task(); This->Task();
} }

@ -93,7 +93,7 @@ protected:
uint16 m_PortOpenStream; uint16 m_PortOpenStream;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
// socket // socket

@ -40,7 +40,7 @@
CWiresxCmdHandler::CWiresxCmdHandler() CWiresxCmdHandler::CWiresxCmdHandler()
{ {
m_seqNo = 0; m_seqNo = 0;
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
} }
@ -51,7 +51,7 @@ CWiresxCmdHandler::CWiresxCmdHandler()
CWiresxCmdHandler::~CWiresxCmdHandler() CWiresxCmdHandler::~CWiresxCmdHandler()
{ {
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -78,7 +78,7 @@ bool CWiresxCmdHandler::Init(void)
m_ReflectorWiresxInfo.SetName("Reflector"); m_ReflectorWiresxInfo.SetName("Reflector");
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// start thread; // start thread;
m_pThread = new std::thread(CWiresxCmdHandler::Thread, this); m_pThread = new std::thread(CWiresxCmdHandler::Thread, this);
@ -89,7 +89,7 @@ bool CWiresxCmdHandler::Init(void)
void CWiresxCmdHandler::Close(void) void CWiresxCmdHandler::Close(void)
{ {
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -103,7 +103,7 @@ void CWiresxCmdHandler::Close(void)
void CWiresxCmdHandler::Thread(CWiresxCmdHandler *This) void CWiresxCmdHandler::Thread(CWiresxCmdHandler *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
This->Task(); This->Task();
} }

@ -86,7 +86,7 @@ protected:
CWiresxPacketQueue m_PacketQueue; CWiresxPacketQueue m_PacketQueue;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
}; };

@ -33,14 +33,14 @@
CYsfNodeDir::CYsfNodeDir() CYsfNodeDir::CYsfNodeDir()
{ {
m_bStopThread = false; keep_running = true;
m_pThread = NULL; m_pThread = NULL;
} }
CYsfNodeDir::~CYsfNodeDir() CYsfNodeDir::~CYsfNodeDir()
{ {
// kill threads // kill threads
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -58,7 +58,7 @@ bool CYsfNodeDir::Init(void)
Reload(); Reload();
// reset stop flag // reset stop flag
m_bStopThread = false; keep_running = true;
// start thread; // start thread;
m_pThread = new std::thread(CYsfNodeDir::Thread, this); m_pThread = new std::thread(CYsfNodeDir::Thread, this);
@ -68,7 +68,7 @@ bool CYsfNodeDir::Init(void)
void CYsfNodeDir::Close(void) void CYsfNodeDir::Close(void)
{ {
m_bStopThread = true; keep_running = false;
if ( m_pThread != NULL ) if ( m_pThread != NULL )
{ {
m_pThread->join(); m_pThread->join();
@ -82,7 +82,7 @@ void CYsfNodeDir::Close(void)
void CYsfNodeDir::Thread(CYsfNodeDir *This) void CYsfNodeDir::Thread(CYsfNodeDir *This)
{ {
while ( !This->m_bStopThread ) while (This->keep_running)
{ {
// Wait 30 seconds // Wait 30 seconds
CTimePoint::TaskSleepFor(YSFNODEDB_REFRESH_RATE * 60000); CTimePoint::TaskSleepFor(YSFNODEDB_REFRESH_RATE * 60000);

@ -86,7 +86,7 @@ protected:
std::mutex m_Mutex; std::mutex m_Mutex;
// thread // thread
bool m_bStopThread; std::atomic<bool> keep_running;
std::thread *m_pThread; std::thread *m_pThread;
}; };

@ -25,6 +25,7 @@
#ifndef main_h #ifndef main_h
#define main_h #define main_h
#include <atomic>
#include <vector> #include <vector>
#include <array> #include <array>
#include <list> #include <list>

Loading…
Cancel
Save

Powered by TurnKey Linux.