diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-04-17 16:23:39 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-04-26 22:23:09 +0200 |
commit | ce540b296cc76d7dd48d6cdbf40c01e9103a3d4f (patch) | |
tree | 1344ca86ab7cf442a07d0338eb5c54c06008bb16 /desktop/source/lib/init.cxx | |
parent | ad9902f34dd0b5837ab518445ea9f3a24352738b (diff) |
Unipoll: add LibreOfficeKit API for polling, and an option to use it.
Change-Id: Iee7556ee52541ddbf1ef8f31e1ed4697f805a2ac
Reviewed-on: https://gerrit.libreoffice.org/70898
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/71164
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'desktop/source/lib/init.cxx')
-rw-r--r-- | desktop/source/lib/init.cxx | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 35943999d12b..8c4fdb7b4494 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -35,6 +35,7 @@ #include <sal/log.hxx> #include <vcl/errinf.hxx> +#include <vcl/lok.hxx> #include <osl/file.hxx> #include <osl/process.h> #include <osl/thread.h> @@ -1516,6 +1517,11 @@ static bool lo_signDocument(LibreOfficeKit* pThis, const unsigned char* pPrivateKeyBinary, const int nPrivateKeyBinarySize); +static void lo_runLoop(LibreOfficeKit* pThis, + LibreOfficeKitPollCallback pPollCallback, + LibreOfficeKitWakeCallback pWakeCallback, + void* pData); + LibLibreOffice_Impl::LibLibreOffice_Impl() : m_pOfficeClass( gOfficeClass.lock() ) , maThread(nullptr) @@ -1539,6 +1545,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl() m_pOfficeClass->getVersionInfo = lo_getVersionInfo; m_pOfficeClass->runMacro = lo_runMacro; m_pOfficeClass->signDocument = lo_signDocument; + m_pOfficeClass->runLoop = lo_runLoop; gOfficeClass = m_pOfficeClass; } @@ -4562,6 +4569,16 @@ static void lo_startmain(void*) Application::ReleaseSolarMutex(); } +static void lo_runLoop(LibreOfficeKit* /*pThis*/, + LibreOfficeKitPollCallback pPollCallback, + LibreOfficeKitWakeCallback pWakeCallback, + void* pData) +{ + SolarMutexGuard aGuard; + vcl::lok::registerPollCallbacks(pPollCallback, pWakeCallback, pData); + lo_startmain(nullptr); +} + static bool bInitialized = false; static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit::statusIndicatorCallbackType type, int percent) @@ -4711,7 +4728,24 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char // Did we do a pre-initialize static bool bPreInited = false; - static bool bProfileZones = getenv("SAL_PROFILEZONE_EVENTS") != nullptr; + static bool bUnipoll = false; + static bool bProfileZones = false; + + { // cf. string lifetime for preinit + std::vector<OUString> aOpts; + + // ':' delimited options - avoiding ABI change for new parameters + const char *pOptions = getenv("SAL_LOK_OPTIONS"); + if (pOptions) + aOpts = comphelper::string::split(OUString(pOptions, strlen(pOptions), RTL_TEXTENCODING_UTF8), ':'); + for (auto &it : aOpts) + { + if (it == "unipoll") + bUnipoll = true; + else if (it == "profile_events") + bProfileZones = true; + } + } // What stage are we at ? if (pThis == nullptr) @@ -4924,10 +4958,14 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char RequestHandler::Enable(false); SAL_INFO("lok", "Starting soffice_main"); RequestHandler::SetReady(false); - pLib->maThread = osl_createThread(lo_startmain, nullptr); - SAL_INFO("lok", "Waiting for RequestHandler"); - RequestHandler::WaitForReady(); - SAL_INFO("lok", "RequestHandler ready -- continuing"); + if (!bUnipoll) + { + // Start the main thread only in non-unipoll mode (i.e. multithreaded). + pLib->maThread = osl_createThread(lo_startmain, nullptr); + SAL_INFO("lok", "Waiting for RequestHandler"); + RequestHandler::WaitForReady(); + SAL_INFO("lok", "RequestHandler ready -- continuing"); + } } if (eStage != SECOND_INIT) |