lib/ipc: Use standard mutex primitives in IpcLogOutputter
This commit is contained in:
parent
489f45fc94
commit
0a89b5abfe
|
@ -41,8 +41,6 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType
|
||||||
m_sending(false),
|
m_sending(false),
|
||||||
m_bufferThread(nullptr),
|
m_bufferThread(nullptr),
|
||||||
m_running(false),
|
m_running(false),
|
||||||
m_notifyCond(ARCH->newCondVar()),
|
|
||||||
m_notifyMutex(ARCH->newMutex()),
|
|
||||||
m_bufferWaiting(false),
|
m_bufferWaiting(false),
|
||||||
m_bufferThreadId(0),
|
m_bufferThreadId(0),
|
||||||
m_bufferMaxSize(kBufferMaxSize),
|
m_bufferMaxSize(kBufferMaxSize),
|
||||||
|
@ -66,9 +64,6 @@ IpcLogOutputter::~IpcLogOutputter()
|
||||||
m_bufferThread->wait();
|
m_bufferThread->wait();
|
||||||
delete m_bufferThread;
|
delete m_bufferThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARCH->closeCondVar(m_notifyCond);
|
|
||||||
ARCH->closeMutex(m_notifyMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -148,8 +143,8 @@ void IpcLogOutputter::buffer_thread()
|
||||||
try {
|
try {
|
||||||
while (isRunning()) {
|
while (isRunning()) {
|
||||||
if (m_buffer.empty() || !m_ipcServer.hasClients(m_clientType)) {
|
if (m_buffer.empty() || !m_ipcServer.hasClients(m_clientType)) {
|
||||||
ArchMutexLock lock(m_notifyMutex);
|
std::unique_lock<std::mutex> lock(notify_mutex_);
|
||||||
ARCH->waitCondVar(m_notifyCond, lock, -1);
|
ARCH->wait_cond_var(notify_cv_, lock, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendBuffer();
|
sendBuffer();
|
||||||
|
@ -165,8 +160,8 @@ void IpcLogOutputter::buffer_thread()
|
||||||
void
|
void
|
||||||
IpcLogOutputter::notifyBuffer()
|
IpcLogOutputter::notifyBuffer()
|
||||||
{
|
{
|
||||||
ArchMutexLock lock(m_notifyMutex);
|
std::lock_guard<std::mutex> lock(notify_mutex_);
|
||||||
ARCH->broadcastCondVar(m_notifyCond);
|
notify_cv_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IpcLogOutputter::getChunk(size_t count)
|
std::string IpcLogOutputter::getChunk(size_t count)
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "ipc/Ipc.h"
|
#include "ipc/Ipc.h"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
class IpcServer;
|
class IpcServer;
|
||||||
|
@ -106,8 +107,8 @@ private:
|
||||||
bool m_sending;
|
bool m_sending;
|
||||||
Thread* m_bufferThread;
|
Thread* m_bufferThread;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
ArchCond m_notifyCond;
|
std::condition_variable notify_cv_;
|
||||||
ArchMutex m_notifyMutex;
|
std::mutex notify_mutex_;
|
||||||
bool m_bufferWaiting;
|
bool m_bufferWaiting;
|
||||||
IArchMultithread::ThreadID
|
IArchMultithread::ThreadID
|
||||||
m_bufferThreadId;
|
m_bufferThreadId;
|
||||||
|
|
Loading…
Reference in New Issue