diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-04-17 16:23:39 +0100 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2019-04-23 02:59:45 +0200 |
commit | b34786d2774b261be48de92f65a5d0aa3c32b289 (patch) | |
tree | 0acaf342c3e93465777a0aeca0568bdaec3c1bc7 /desktop | |
parent | 9f32d341b80e1f1ffe28542f33003bfe5750639b (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>
Diffstat (limited to 'desktop')
-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 0842c98ed3e4..0853678a0008 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -39,6 +39,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> @@ -1513,6 +1514,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) @@ -1536,6 +1542,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; } @@ -4491,6 +4498,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) @@ -4639,7 +4656,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) @@ -4857,10 +4891,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) |