[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/Makefile.am loolwsd/QueueHandler.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed Jan 6 06:23:57 PST 2016


 loolwsd/LOOLKit.cpp      |   52 -------------------------------------
 loolwsd/Makefile.am      |    1 
 loolwsd/QueueHandler.hpp |   66 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+), 51 deletions(-)

New commits:
commit c3826587e10af8208ffd160b0077c245d85f92d6
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Jan 6 08:18:56 2016 -0500

    loolwsd: moved QueueHandler into own file
    
    Change-Id: I281a9bd12731340673cb66f1f2ac6a133cbe71d0
    Reviewed-on: https://gerrit.libreoffice.org/21159
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 04d5e80..c352422 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -38,7 +38,7 @@
 #include <LibreOfficeKit/LibreOfficeKitInit.h>
 
 #include "Common.hpp"
-#include "MessageQueue.hpp"
+#include "QueueHandler.hpp"
 #include "Util.hpp"
 #include "ChildProcessSession.hpp"
 #include "LOOLProtocol.hpp"
@@ -316,56 +316,6 @@ private:
 
 FastMutex CallBackWorker::_mutex;
 
-// This thread handles incoming messages
-// on a given kit instance.
-class QueueHandler: public Runnable
-{
-public:
-    QueueHandler(MessageQueue& queue, const std::shared_ptr<LOOLSession>& session):
-        _queue(queue),
-        _session(session)
-    {
-    }
-
-    void run() override
-    {
-        static const std::string thread_name = "kit_queue_" + _session->getId();
-#ifdef __linux
-        if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
-            Log::error("Cannot set thread name to " + thread_name + ".");
-#endif
-        Log::debug("Thread [" + thread_name + "] started.");
-
-        try
-        {
-            while (true)
-            {
-                const std::string input = _queue.get();
-                if (input == "eof")
-                    break;
-                if (!_session->handleInput(input.c_str(), input.size()))
-                    break;
-            }
-        }
-        catch (const std::exception& exc)
-        {
-            Log::error(std::string("Exception: ") + exc.what());
-            raise(SIGABRT);
-        }
-        catch (...)
-        {
-            Log::error("Unexpected Exception.");
-            raise(SIGABRT);
-        }
-
-        Log::debug("Thread [" + thread_name + "] finished.");
-    }
-
-private:
-    MessageQueue& _queue;
-    std::shared_ptr<LOOLSession> _session;
-};
-
 class Connection: public Runnable
 {
 public:
diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index 4e219ea..24237e0 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -29,6 +29,7 @@ loolmap_SOURCES = loolmap.c
 
 noinst_HEADERS = LOKitHelper.hpp LOOLProtocol.hpp LOOLSession.hpp MasterProcessSession.hpp ChildProcessSession.hpp \
                  LOOLWSD.hpp LoadTest.hpp MessageQueue.hpp TileCache.hpp Util.hpp Png.hpp Common.hpp Capabilities.hpp \
+				 QueueHandler.hpp \
                  bundled/include/LibreOfficeKit/LibreOfficeKit.h bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKitInit.h bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h
 
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
new file mode 100644
index 0000000..5d07b9a
--- /dev/null
+++ b/loolwsd/QueueHandler.hpp
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <Poco/Runnable.h>
+
+#include "MessageQueue.hpp"
+#include "LOOLSession.hpp"
+#include "Util.hpp"
+
+// This thread handles incoming messages
+// on a given kit instance.
+class QueueHandler: public Poco::Runnable
+{
+public:
+    QueueHandler(MessageQueue& queue, const std::shared_ptr<LOOLSession>& session):
+        _queue(queue),
+        _session(session)
+    {
+    }
+
+    void run() override
+    {
+        static const std::string thread_name = "kit_queue_" + _session->getId();
+#ifdef __linux
+        if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
+            Log::error("Cannot set thread name to " + thread_name + ".");
+#endif
+        Log::debug("Thread [" + thread_name + "] started.");
+
+        try
+        {
+            while (true)
+            {
+                const std::string input = _queue.get();
+                if (input == "eof")
+                    break;
+                if (!_session->handleInput(input.c_str(), input.size()))
+                    break;
+            }
+        }
+        catch (const std::exception& exc)
+        {
+            Log::error(std::string("Exception: ") + exc.what());
+            raise(SIGABRT);
+        }
+        catch (...)
+        {
+            Log::error("Unexpected Exception.");
+            raise(SIGABRT);
+        }
+
+        Log::debug("Thread [" + thread_name + "] finished.");
+    }
+
+private:
+    MessageQueue& _queue;
+    std::shared_ptr<LOOLSession> _session;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list