Use std::mutex instead of ArchMutex in IpcClientProxy
This commit is contained in:
parent
36f3235f51
commit
93c04bb2fa
|
@ -34,8 +34,6 @@ IpcClientProxy::IpcClientProxy(barrier::IStream& stream, IEventQueue* events) :
|
||||||
m_stream(stream),
|
m_stream(stream),
|
||||||
m_clientType(kIpcClientUnknown),
|
m_clientType(kIpcClientUnknown),
|
||||||
m_disconnecting(false),
|
m_disconnecting(false),
|
||||||
m_readMutex(ARCH->newMutex()),
|
|
||||||
m_writeMutex(ARCH->newMutex()),
|
|
||||||
m_events(events)
|
m_events(events)
|
||||||
{
|
{
|
||||||
m_events->adoptHandler(
|
m_events->adoptHandler(
|
||||||
|
@ -71,14 +69,11 @@ IpcClientProxy::~IpcClientProxy()
|
||||||
m_events->forIStream().outputShutdown(), m_stream.getEventTarget());
|
m_events->forIStream().outputShutdown(), m_stream.getEventTarget());
|
||||||
|
|
||||||
// don't delete the stream while it's being used.
|
// don't delete the stream while it's being used.
|
||||||
ARCH->lockMutex(m_readMutex);
|
{
|
||||||
ARCH->lockMutex(m_writeMutex);
|
std::lock_guard<std::mutex> lock_read(m_readMutex);
|
||||||
delete &m_stream;
|
std::lock_guard<std::mutex> lock_write(m_writeMutex);
|
||||||
ARCH->unlockMutex(m_readMutex);
|
delete &m_stream;
|
||||||
ARCH->unlockMutex(m_writeMutex);
|
}
|
||||||
|
|
||||||
ARCH->closeMutex(m_readMutex);
|
|
||||||
ARCH->closeMutex(m_writeMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -99,7 +94,7 @@ void
|
||||||
IpcClientProxy::handleData(const Event&, void*)
|
IpcClientProxy::handleData(const Event&, void*)
|
||||||
{
|
{
|
||||||
// don't allow the dtor to destroy the stream while we're using it.
|
// don't allow the dtor to destroy the stream while we're using it.
|
||||||
ArchMutexLock lock(m_readMutex);
|
std::lock_guard<std::mutex> lock(m_readMutex);
|
||||||
|
|
||||||
LOG((CLOG_DEBUG "start ipc handle data"));
|
LOG((CLOG_DEBUG "start ipc handle data"));
|
||||||
|
|
||||||
|
@ -139,7 +134,7 @@ IpcClientProxy::send(const IpcMessage& message)
|
||||||
// don't allow other threads to write until we've finished the entire
|
// don't allow other threads to write until we've finished the entire
|
||||||
// message. stream write is locked, but only for that single write.
|
// message. stream write is locked, but only for that single write.
|
||||||
// also, don't allow the dtor to destroy the stream while we're using it.
|
// also, don't allow the dtor to destroy the stream while we're using it.
|
||||||
ArchMutexLock lock(m_writeMutex);
|
std::lock_guard<std::mutex> lock(m_writeMutex);
|
||||||
|
|
||||||
LOG((CLOG_DEBUG4 "ipc write: %d", message.type()));
|
LOG((CLOG_DEBUG4 "ipc write: %d", message.type()));
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace barrier { class IStream; }
|
namespace barrier { class IStream; }
|
||||||
class IpcMessage;
|
class IpcMessage;
|
||||||
class IpcCommandMessage;
|
class IpcCommandMessage;
|
||||||
|
@ -49,7 +51,7 @@ private:
|
||||||
barrier::IStream& m_stream;
|
barrier::IStream& m_stream;
|
||||||
EIpcClientType m_clientType;
|
EIpcClientType m_clientType;
|
||||||
bool m_disconnecting;
|
bool m_disconnecting;
|
||||||
ArchMutex m_readMutex;
|
std::mutex m_readMutex;
|
||||||
ArchMutex m_writeMutex;
|
std::mutex m_writeMutex;
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue