if (CreateThread())
{
- m_controller->AddLog(CEC_LOG_DEBUG, "communication thread created");
+ m_startCondition.Wait(&m_mutex);
+ m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started");
return true;
}
else
void CAdapterCommunication::Close(void)
{
CLockObject lock(&m_mutex);
- StopThread();
-
+ m_startCondition.Broadcast();
m_rcvCondition.Broadcast();
+ StopThread();
}
void *CAdapterCommunication::Process(void)
{
- m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started");
+ {
+ CLockObject lock(&m_mutex);
+ m_startCondition.Signal();
+ }
while (!IsStopped())
{
bool CAdapterCommunication::IsOpen(void) const
{
- return !IsStopped() && m_port->IsOpen();
+ return !IsStopped() && m_port->IsOpen() && IsRunning();
}