[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/MasterProcessSession.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Dec 25 20:00:08 PST 2015
loolwsd/ChildProcessSession.cpp | 1 -
loolwsd/LOOLKit.cpp | 13 ++++---------
loolwsd/LOOLWSD.cpp | 6 +++---
loolwsd/MasterProcessSession.cpp | 7 ++++---
4 files changed, 11 insertions(+), 16 deletions(-)
New commits:
commit ab8c6e66618a0522426006bd74b2206d06ecbb02
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri Dec 25 22:51:09 2015 -0500
loolwsd: use make_shared and emplace
Change-Id: I9110a03b69442f0f8a674eda6ab4cf20462557c1
Reviewed-on: https://gerrit.libreoffice.org/20951
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 5eeda67..786fbb6 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -261,7 +261,6 @@ bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTok
Log::info("Local URI: [" + aUri.toString() + "].");
}
-
if (_loKitDocument != nullptr)
{
_viewId = _loKitDocument->pClass->createView(_loKitDocument);
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 6f14936..6c9b311 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -364,7 +364,7 @@ public:
cs.setTimeout(0);
HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI);
HTTPResponse response;
- std::shared_ptr<WebSocket> ws(new WebSocket(cs, request, response));
+ auto ws = std::make_shared<WebSocket>(cs, request, response);
_session.reset(new ChildProcessSession(ws, _loKit, _loKitDocument, std::to_string(_childId)));
ws->setReceiveTimeout(0);
@@ -579,21 +579,16 @@ void run_lok_main(const std::string &loSubPath, Poco::UInt64 _childId, const std
if ( _connections.empty() )
{
Log::info("Creating main thread for child: " + std::to_string(_childId) + ", thread: " + threadId);
- thread = std::shared_ptr<Connection>(new Connection(loKit, nullptr, _childId, threadId));
+ thread = std::make_shared<Connection>(loKit, nullptr, _childId, threadId);
}
else
{
Log::info("Creating view thread for child: " + std::to_string(_childId) + ", thread: " + threadId);
auto aConnection = _connections.begin();
- thread = std::shared_ptr<Connection>(new Connection(loKit, aConnection->second->getLOKitDocument(), _childId, threadId));
+ thread = std::make_shared<Connection>(loKit, aConnection->second->getLOKitDocument(), _childId, threadId);
}
- auto aInserted = _connections.insert(
- std::pair<std::string, std::shared_ptr<Connection>>
- (
- threadId,
- thread
- ));
+ auto aInserted = _connections.emplace(threadId, thread);
if ( aInserted.second )
thread->start();
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 8b100d4..a046ad2 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -339,7 +339,7 @@ public:
// Load the document.
std::shared_ptr<WebSocket> ws;
LOOLSession::Kind kind = LOOLSession::Kind::ToClient;
- std::shared_ptr<MasterProcessSession> session(new MasterProcessSession(ws, kind));
+ auto session = std::make_shared<MasterProcessSession>(ws, kind);
const std::string filePrefix("file://");
const std::string load = "load url=" + filePrefix + fromPath;
session->handleInput(load.data(), load.size());
@@ -440,7 +440,7 @@ public:
{
try
{
- std::shared_ptr<WebSocket> ws(new WebSocket(request, response));
+ auto ws = std::make_shared<WebSocket>(request, response);
LOOLSession::Kind kind;
@@ -449,7 +449,7 @@ public:
else
kind = LOOLSession::Kind::ToClient;
- std::shared_ptr<MasterProcessSession> session(new MasterProcessSession(ws, kind));
+ auto session = std::make_shared<MasterProcessSession>(ws, kind);
// For ToClient sessions, we store incoming messages in a queue and have a separate
// thread that handles them. This is so that we can empty the queue when we get a
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index 3766111..c466ad2 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -211,9 +211,10 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length)
Process::PID pidChild = std::stoull(tokens[3]);
std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
- _availableChildSessions.insert(std::pair<Thread::TID, std::shared_ptr<MasterProcessSession>> (tId, shared_from_this()));
+ _availableChildSessions.emplace(tId, shared_from_this());
- Log::info() << _kindString << ",Inserted " << this << " id=" << childId << " into _availableChildSessions, size=" << _availableChildSessions.size() << Log::end;
+ Log::info() << _kindString << " mapped " << this << " id=" << childId << ", tId=" << tId
+ << " into _availableChildSessions, size=" << _availableChildSessions.size() << Log::end;
_childId = childId;
_pidChild = pidChild;
@@ -558,7 +559,7 @@ void MasterProcessSession::dispatchChild()
std::shared_ptr<MasterProcessSession> childSession;
std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
- Log::debug() << "Waiting for a child session permission for thead [" << Thread::currentTid() << "]." << Log::end;
+ Log::debug() << "Waiting for a child session permission for thread [" << Thread::currentTid() << "]." << Log::end;
while (nRequest-- && !bFound)
{
_availableChildSessionCV.wait_for(
More information about the Libreoffice-commits
mailing list