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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save

Powered by TurnKey Linux.