lib/ipc: Use standard mutex primitives in IpcLogOutputter

This commit is contained in:
Povilas Kanapickas 2021-11-03 02:58:32 +02:00
parent 489f45fc94
commit 0a89b5abfe
2 changed files with 7 additions and 11 deletions

View File

@ -41,8 +41,6 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType
m_sending(false),
m_bufferThread(nullptr),
m_running(false),
m_notifyCond(ARCH->newCondVar()),
m_notifyMutex(ARCH->newMutex()),
m_bufferWaiting(false),
m_bufferThreadId(0),
m_bufferMaxSize(kBufferMaxSize),
@ -66,9 +64,6 @@ IpcLogOutputter::~IpcLogOutputter()
m_bufferThread->wait();
delete m_bufferThread;
}
ARCH->closeCondVar(m_notifyCond);
ARCH->closeMutex(m_notifyMutex);
}
void
@ -148,8 +143,8 @@ void IpcLogOutputter::buffer_thread()
try {
while (isRunning()) {
if (m_buffer.empty() || !m_ipcServer.hasClients(m_clientType)) {
ArchMutexLock lock(m_notifyMutex);
ARCH->waitCondVar(m_notifyCond, lock, -1);
std::unique_lock<std::mutex> lock(notify_mutex_);
ARCH->wait_cond_var(notify_cv_, lock, -1);
}
sendBuffer();
@ -165,8 +160,8 @@ void IpcLogOutputter::buffer_thread()
void
IpcLogOutputter::notifyBuffer()
{
ArchMutexLock lock(m_notifyMutex);
ARCH->broadcastCondVar(m_notifyCond);
std::lock_guard<std::mutex> lock(notify_mutex_);
notify_cv_.notify_all();
}
std::string IpcLogOutputter::getChunk(size_t count)

View File

@ -25,6 +25,7 @@
#include "ipc/Ipc.h"
#include <deque>
#include <condition_variable>
#include <mutex>
class IpcServer;
@ -106,8 +107,8 @@ private:
bool m_sending;
Thread* m_bufferThread;
bool m_running;
ArchCond m_notifyCond;
ArchMutex m_notifyMutex;
std::condition_variable notify_cv_;
std::mutex notify_mutex_;
bool m_bufferWaiting;
IArchMultithread::ThreadID
m_bufferThreadId;