summaryrefslogtreecommitdiff
path: root/include/vcl/scheduler.hxx
AgeCommit message (Collapse)Author
2020-12-07Make SchedulerMutex non-recursiveJan-Marek Glogowski
While thinking about the "Unlock scheduler in deinit for ProcessEventsToIdle" patch, I came to the conclusion, that this mutex should actually be non-recursive. I had a look at the code and did run "make check" for my symbol build on Linux, but for the rest I'm reying on the LO CI. Maybe this can be converted to a std::mutex later. I've updated the vcl/README.scheduler and added a TODO. Change-Id: Ib9cb086af74b51e48f99ebfa1201d14db12b140e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107254 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2020-12-07Unlock scheduler in deinit for ProcessEventsToIdleJan-Marek Glogowski
The scheduler is normally never locked when not processing its own task lists. So while the fix is correct, that ProcessEventsToIdle shouldn't run with a locked scheduler, just unlock it in the actual shutdown case, where the deadlock occurred. This also reverts commit 46f6b39c6d8acd064bafb2416feba757ba0d0fbc. Change-Id: If1603c1563772dd1d156dc6d9bcddbf58aa721c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107241 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2020-12-04Unlock scheduler when calling ProcessEventsToIdleMike Kaganski
When processing the events, solar mutex will be temporarily released, and then it's possible that another thread will acquire solar mutex and try to lock scheduler. This will result in deadlock. Seen in CppunitTest_sw_core_undo that deadlocked locally on Windows frequently. Main thread call stack: win32u.dll!NtUserMsgWaitForMultipleObjectsEx() user32.dll!RealMsgWaitForMultipleObjectsEx() sal3.dll!osl_waitCondition(void * Condition, const TimeValue * pTimeout) Line 82 vclplug_winlo.dll!osl::Condition::wait(const TimeValue * pTimeout) Line 120 vclplug_winlo.dll!SalYieldMutex::doAcquire(unsigned long nLockCount) Line 159 comphelper.dll!comphelper::SolarMutex::acquire(unsigned long nLockCount) Line 87 vclplug_winlo.dll!ImplSalYieldMutexAcquireWithWait(unsigned long nCount) Line 204 vclplug_winlo.dll!WinSalTimer::ImplHandleElapsedTimer() Line 163 vclplug_winlo.dll!WinSalTimer::ImplHandle_WM_TIMER(unsigned __int64 aWPARAM) Line 197 vclplug_winlo.dll!SalComWndProc(HWND__ * __formal, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 638 vclplug_winlo.dll!SalComWndProcW(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 665 user32.dll!UserCallWinProcCheckWow() user32.dll!DispatchMessageWorker() vclplug_winlo.dll!ImplSalDispatchMessage(const tagMSG * pMsg) Line 426 vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 457 vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 528 vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 447 vcllo.dll!Application::Reschedule(bool i_bAllEvents) Line 461 vcllo.dll!Scheduler::ProcessEventsToIdle() Line 466 vcllo.dll!Scheduler::ImplDeInitScheduler() Line 129 vcllo.dll!DeInitVCL() Line 483 vclbootstrapprotector.dll!`anonymous namespace'::Protector::~Protector() Line 34 vclbootstrapprotector.dll!`anonymous namespace'::Protector::`scalar deleting destructor'(unsigned int) cppunitd_dll.dll!CppUnit::ProtectorChain::pop() Line 56 cppunitd_dll.dll!CppUnit::TestResult::popProtector() Line 197 cppunittester.exe!`anonymous namespace'::ProtectedFixtureFunctor::run() Line 332 cppunittester.exe!sal_main() Line 473 cppunittester.exe!main(int argc, char * * argv) Line 380 cppunittester.exe!invoke_main() Line 79 cppunittester.exe!__scrt_common_main_seh() Line 288 cppunittester.exe!__scrt_common_main() Line 331 cppunittester.exe!mainCRTStartup() Line 17 kernel32.dll!BaseThreadInitThunk() ntdll.dll!RtlUserThreadStart() Clipboard thread call stack: ntdll.dll!NtWaitForAlertByThreadId() ntdll.dll!RtlpWaitOnAddressWithTimeout() ntdll.dll!RtlpWaitOnAddress() ntdll.dll!RtlpWaitOnCriticalSection() ntdll.dll!RtlpEnterCriticalSectionContended() ntdll.dll!RtlEnterCriticalSection() sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex) Line 66 vcllo.dll!osl::Mutex::acquire() Line 57 vcllo.dll!SchedulerMutex::acquire(unsigned long nLockCount) Line 213 vcllo.dll!Scheduler::Lock(unsigned long nLockCount) Line 237 vcllo.dll!SchedulerGuard::SchedulerGuard() Line 60 vcllo.dll!Task::~Task() Line 660 vcllo.dll!Timer::~Timer() Line 61 vcllo.dll!Idle::~Idle() svxcorelo.dll!SdrPaintView::~SdrPaintView() Line 189 svxcorelo.dll!SdrSnapView::~SdrSnapView() Line 200 svxcorelo.dll!SdrMarkView::~SdrMarkView() Line 193 svxcorelo.dll!SdrEditView::~SdrEditView() Line 125 svxcorelo.dll!SdrPolyEditView::~SdrPolyEditView() Line 58 svxcorelo.dll!SdrGlueEditView::~SdrGlueEditView() Line 40 svxcorelo.dll!SdrObjEditView::~SdrObjEditView() Line 95 svxcorelo.dll!SdrExchangeView::~SdrExchangeView() svxcorelo.dll!SdrDragView::~SdrDragView() Line 65 svxcorelo.dll!SdrCreateView::~SdrCreateView() Line 200 svxcorelo.dll!SdrView::~SdrView() Line 159 swlo.dll!SdrView::`scalar deleting destructor'(unsigned int) swlo.dll!std::default_delete<SdrView>::operator()(SdrView * _Ptr) Line 2537 swlo.dll!std::unique_ptr<SdrView,std::default_delete<SdrView>>::~unique_ptr<SdrView,std::default_delete<SdrView>>() Line 2649 swlo.dll!SwDrawFrameFormat::MakeGraphic(ImageMap * __formal) Line 7491 swlo.dll!OutHTML_FrameFormatAsImage(Writer & rWrt, const SwFrameFormat & rFrameFormat) Line 1746 swlo.dll!SwHTMLWriter::OutFrameFormat(AllHtmlFlags nMode, const SwFrameFormat & rFrameFormat, const SdrObject * pSdrObject) Line 507 swlo.dll!SwHTMLWriter::OutFlyFrame(unsigned __int64 nNdIdx, long nContentIdx, HtmlPosition nPos, HTMLOutContext * pContext) Line 401 swlo.dll!OutHTML_SwTextNode(Writer & rWrt, const SwContentNode & rNode) Line 2509 swlo.dll!SwHTMLWriter::Out_SwDoc(SwPaM * pPam) Line 834 swlo.dll!SwHTMLWriter::WriteStream() Line 471 swlo.dll!Writer::Write(SwPaM & rPaM, SvStream & rStrm, const rtl::OUString * pFName) Line 272 swlo.dll!SwWriter::Write(const tools::SvRef<Writer> & rxWriter, const rtl::OUString * pRealFileName) Line 861 swlo.dll!SwTransferable::WriteObject(tools::SvRef<SotStorageStream> & xStream, void * pObject, unsigned long nObjectType, const com::sun::star::datatransfer::DataFlavor & __formal) Line 823 vcllo.dll!TransferableHelper::SetObject(void * pUserObject, unsigned long nUserObjectId, const com::sun::star::datatransfer::DataFlavor & rFlavor) Line 879 swlo.dll!SwTransferable::GetData(const com::sun::star::datatransfer::DataFlavor & rFlavor, const rtl::OUString & rDestDoc) Line 619 vcllo.dll!TransferableHelper::getTransferData2(const com::sun::star::datatransfer::DataFlavor & rFlavor, const rtl::OUString & rDestDoc) Line 389 vcllo.dll!TransferableHelper::getTransferData(const com::sun::star::datatransfer::DataFlavor & rFlavor) Line 287 vclplug_winlo.dll!CXTDataObject::renderSynthesizedHtmlAndSetupStgMedium(tagFORMATETC & fetc, tagSTGMEDIUM & stgmedium) Line 516 vclplug_winlo.dll!CXTDataObject::renderSynthesizedFormatAndSetupStgMedium(tagFORMATETC & fetc, tagSTGMEDIUM & stgmedium) Line 419 vclplug_winlo.dll!`CXTDataObject::GetData'::`1'::catch$1() Line 269 vcruntime140_1d.dll!_CallSettingFrame_LookupContinuationIndex() Line 98 vcruntime140_1d.dll!__FrameHandler4::CxxCallCatchBlock(_EXCEPTION_RECORD * pExcept) Line 1367 ntdll.dll!RcConsolidateFrames() vclplug_winlo.dll!CXTDataObject::GetData(tagFORMATETC * pFormatetc, tagSTGMEDIUM * pmedium) Line 261 vclplug_winlo.dll!CXNotifyingDataObject::GetData(tagFORMATETC * pFormatetc, tagSTGMEDIUM * pmedium) Line 86 ole32.dll!HandleFromHandle(IDataObject * pDataObj, tagFORMATETC * pformatetc, tagSTGMEDIUM * pmedium) Line 2048 ole32.dll!RenderCurrentFormat(HWND__ * hClipWnd, unsigned int cf, tagSTGMEDIUM * pmedium, IDataObject * pDataObj) Line 4057 ole32.dll!RenderFormat(HWND__ * hClipWnd, unsigned int cf, IDataObject * pDataObj, void * pvMTADataObject) Line 4191 ole32.dll!ClipboardWndProc(HWND__ * hWnd, unsigned int msg, unsigned __int64 wParam, __int64 lParam) Line 683 user32.dll!UserCallWinProcCheckWow() user32.dll!DispatchClientMessage() user32.dll!__fnDWORD() ntdll.dll!KiUserCallbackDispatcherContinue() win32u.dll!NtUserGetMessage() user32.dll!GetMessageW() vclplug_winlo.dll!CMtaOleClipboard::run() Line 654 vclplug_winlo.dll!CMtaOleClipboard::oleThreadProc(void * pParam) Line 676 ucrtbased.dll!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97 kernel32.dll!BaseThreadInitThunk() ntdll.dll!RtlUserThreadStart() Main thread hold solar mutex when it locked scheduler in ImplDeInitScheduler; then it released solar mutex in WinSalInstance::DoYield, and finally tried to acquire it again in WinSalTimer::ImplHandleElapsedTimer. At the same time, clipboard thread acquired solar mutex in TransferableHelper::getTransferData2. Then it attempted to lock scheduler in Task::~Task. Change-Id: I2ac87c8ac298104043f5b9b5d6760bea0f408f54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107218 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2019-07-29Fix typosAndrea Gelmini
Change-Id: Ic2fb0772648b3f93c2fdfa4d2f663b6ede2ead51 Reviewed-on: https://gerrit.libreoffice.org/76507 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-12-10tdf#42949 Fix IWYU warnings in include/vcl/s*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Ie87d27dd2c385a63349e0b322fd067ba03d2d152 Reviewed-on: https://gerrit.libreoffice.org/64479 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-09-20Replace SAL_DELETED_FUNCTION with = delete in internal codeStephan Bergmann
Change-Id: I23399a4d1869635c8b6ffeb25bd183b0504b448d Reviewed-on: https://gerrit.libreoffice.org/60801 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-29tdf#119458 just wakeup Scheduler on active IdleJan-Marek Glogowski
So this almost returns the code to the original state, before I started fixing tdf#116370... a long way. This introduces the new Scheduler::Wakeup() function, which will just queue a Scheduler event in the System event queue unconditionally. This should prevent fdo#73165, which I couldn't reproduce, but just to be sure. More importantly this patch resets the m_bStartOnUnblock when the Idle job actually runs. This run should already determinates if more Idle work needs to be done, and others can still call BeginIdling() to ensure further processing. This also drops the IsBusyDoc() test from UnblockIdling(). We can't really know, if the document is still busy when the Scheduler is finally running, be it by the system timer or Application::Reschedule(). Change-Id: I6cc4a3c48dcaf62b6985c7bc1c95c96697443f3b Reviewed-on: https://gerrit.libreoffice.org/59730 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2017-09-30Access to ProcessEventsToSignal's bSignal is racyStephan Bergmann
...so spell out its single use, locking the appropriate mutex around the access Change-Id: I8e8f47de1979f5a80cf1ad65e5ec24d25145c463 Reviewed-on: https://gerrit.libreoffice.org/42908 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-26tdf#112288 Clarify Reschedule implementationsJan-Marek Glogowski
Application::Reschedule(true) must just process all currently pending events and ignore all new events generated while processing them. In contrast to Scheduler::ProcessEventsToIdle, this way it can't busy-lock the application with background jobs. This way we also can drop nMaxEvents from the Windows backend. This limit was also never implemented on OSX and for the KDE4 backend it's actually impossible to handle single events, and a call to QAbstractEventDispatcher::processEvents works like this. Also changes various call sites to just process all pending events instead of some made up number of times. Change-Id: I1ab95df89b079cc8c6319a808194fe3127144d1c Reviewed-on: https://gerrit.libreoffice.org/42659 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2017-08-09osl::Mutex::acquire can effectively only fail upon programming errorsStephan Bergmann
...so simplify the design a bit here (and there was no meaningful failure- handling code, anyway) Change-Id: I34bb3a7b5fc56f2213a4d22438f0733e1b65fe4b
2017-08-04Implement VCL Scheduler lockingJan-Marek Glogowski
Replces the SolarMutex scheduler locking by using a distinct mutex included in the scheduler context. It should also get rid of the spurious assert( !bAniIdle ) failures, as the test now holds the Scheduler lock for the whole time. This includes reverting the additional scheduler de-init from commit 2e29a518b04250b5f9cc9d0d77da3df076834d60, as I couldn't reproduce the bug running the unit test in valgrind. Change-Id: If33f815fe86c8f82175e96adceb1084b925319dd Reviewed-on: https://gerrit.libreoffice.org/40497 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2017-07-25loplugin:unusedmethodsNoel Grandin
Change-Id: Ia874baf21257e5fe41e104211068a2bcc50446eb Reviewed-on: https://gerrit.libreoffice.org/40391 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-13Drop Task::ReadyForScheduleJan-Marek Glogowski
All relevant information is also provided by UpdateMinPeriod and the calculations were even duplicated. This also includes dropping Scheduler::UpdateMinPeriod, as this is now reduced to a simple comparison and assignment, as we simply ignore larger returned sleep times. Change-Id: I13852e3e63daead451bf7fcb98be9b1d44bd7abd
2017-07-13Run LO scheduler only via system timerJan-Marek Glogowski
Change-Id: I5283f18aebcd6797ad35771ae8fc4a0f425ff924
2017-07-13Run Idle tasks immediatlyJan-Marek Glogowski
There is really no reason to wait a millisecond for an idle. Change-Id: I7665d5f2e7d6ba3e01290a692bbc8e42c36b9986
2017-07-13Introduce a scheduler stackJan-Marek Glogowski
While the stack removes all invoked tasks from the queue, which actively removes it from scheduling, it also helps to faster handle nested calls, as we don't have to look for the previous position to move the task to the end of the queue for the round robin. Change-Id: I358cf2492e9630f67685a2b780509edb56691830
2017-07-13Correctly account starting tasksJan-Marek Glogowski
When (re-)starting the system timer for new task, we have to take the already passed time into account to correctly set the new timeout time for the system timer. Change-Id: I1c1c61b3e54bd14d9451c53150251534b2a960f0
2017-07-13Drop special idle handlingJan-Marek Glogowski
Idles are just instant timers, which should most time have a low priority, By dropping most special idle handling we'll just schedule by priority. This also reverts SalYieldResult back to a bool, which just indicates if any event was processed. Change-Id: Ia0b91b06dffb77af066f01838d8f9483523bf67d
2017-07-13Just walk the task list onceJan-Marek Glogowski
This refactors some more scheduler code by merging the code from ProcessTaskScheduling into CalculateMinimumTimeout and keeping the ProcessTaskScheduling name. It replace the bHasPendingIdles information with a HasPendingTasks function, based on the sleep timeout and invoke time. To drop IsIdle() we simply account Idles again and stop the system timer, so we instantly run our application loop again. This makes all Tasks really run immediate instead of waiting 1ms. Change-Id: I690a8754e6b115a53e74ef777e988b66b4e5037f
2017-07-13Move scheduler task into its own headerJan-Marek Glogowski
Change-Id: I54534787b8cfa4c47dc09dde9c38a7893df9d367
2017-06-06add COVERITY_NOEXCEPT_FALSECaolán McNamara
to markup dtors that coverity warns might throw exceptions which won't throw in practice, or where std::terminate is an acceptable response if they do Change-Id: I32b94814e8245372e1d1dc36be0d81e3564042f4 Reviewed-on: https://gerrit.libreoffice.org/38318 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-03-03Remove redundant 'inline' keywordStephan Bergmann
...from function definitions occurring within class definitions. Done with a rewriting Clang plugin (to be pushed later). Change-Id: I9c6f2818a57ccdb361548895a7743107cbacdff8 Reviewed-on: https://gerrit.libreoffice.org/34874 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-03Remove uses of SAL_CONSTEXPR in LIBO_INTERNAL_ONLYStephan Bergmann
Change-Id: I9a7dc7c83302b3361f056fcf6636bbba7672f15f Reviewed-on: https://gerrit.libreoffice.org/34840 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-02-27uitest: add scheduler method that runs until a signal is receivedMarkus Mohrhard
The other method only runs 1000 events. Change-Id: I43076988e9e25b35e3fdfd8dff19270d9e066d9a Reviewed-on: https://gerrit.libreoffice.org/34690 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2017-01-20Apply stricter member access control for TasksJan-Marek Glogowski
This disallows changing mbAuto and changing values of ImplSchedulerData outside of Scheduler / Task functions. Change-Id: Ia624999bd63190c072eb66427aec38e7ac8cfa1b Reviewed-on: https://gerrit.libreoffice.org/33317 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2017-01-17loplugin:staticmethodsTor Lillqvist
Change-Id: I8864342b6ffd2c63c231ca4d72220a8242da24ca
2017-01-17Refactor Scheduler to add Task classJan-Marek Glogowski
Moves all the "task-specific" stuff into a Task class and just keeps the "real" static Scheduler functions in the original Scheduler class. Change-Id: I9eb02d46e2bcf1abb06af5bab1fa0ee734d1984c
2017-01-17Convert bTimer => bIdleJan-Marek Glogowski
All other places already refer to being Idle, so change the Scheduler::ProcessTaskScheduling argument to bIdle and adapt all other scheduler-related functions. Change-Id: If5a605abbc3e620092127b65ada29f11215a0343
2016-11-09Revert "Mark Scheduler as non-copyable"Stephan Bergmann
This reverts commit 81e3f5f2fdc9c573c83a37009080e4bb974c7955; had failed to notice that there are already (Scheduler const & overloads of) copy member functions (which MSVC complains about, but Clang didn't).
2016-11-09Mark Scheduler as non-copyableStephan Bergmann
Change-Id: Iaabc92061a1a49720f473d35251d892dd4b4f756
2016-09-15loplugin:countusersofdefaultparams in vclNoel Grandin
Change-Id: I046e6f16c5b171a06e2be2da2f72340634f3e979 Reviewed-on: https://gerrit.libreoffice.org/28891 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-05-31tdf#100092: Deterministic scheduling to prevent unpredictable behavior.Jan Holesovsky
Low priority idles can fire more or less randomly, and consequently two consequent runs of LibreOffice differ in the amount of the idles that have been performed during an operation. This commit adds a possibility to turn on a 'deterministic mode' where two subsequent runs of LibreOffice trigger about the same amount of events when they perform the same set of operations. Change-Id: I92566ef4eee20e7d604cfd48f01c4df30c77e653
2016-01-12tdf#97075 - don't render sdr overlays before we paint.Michael Meeks
Change-Id: I0b22af14c7dd684c25cfee26e8c12b95b40479ee Reviewed-on: https://gerrit.libreoffice.org/21400 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-01-12Bin unnecessary forward declarationTor Lillqvist
Change-Id: Iae574695c299b458cc1fa1c7f7709828ffc21527
2016-01-08vcl: silence doxygen warningChris Sherlock
Change-Id: I132672582136abfcec0eeafd2400757def824dbf
2015-12-08Make ImplSVData private to vclTor Lillqvist
Change-Id: I1df6ba8a269be3e165ff5948af1dd12e0bdc6f7d
2015-11-26vcl: fix event processing to idle - for JUnit tests.Michael Meeks
Change-Id: Ibeb1f6627815fc34c6e166357c88e076b75f6abb Reviewed-on: https://gerrit.libreoffice.org/20197 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-25vcl: cleanup scheduler debug name usage.Michael Meeks
Change-Id: I94975d220452ca91cbbd9db5e7895fa0b3a88e4a
2015-11-25vcl: don't treat non-ready timers as idle handlers.Michael Meeks
Fixes the busy-loop - 100% CPU all the time. Change-Id: I965f62d6a6f2ec1830c0897dd97179a739c70afc Reviewed-on: https://gerrit.libreoffice.org/20186 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-25vcl: move private impl. detail of Scheduler out of global header.Michael Meeks
Change-Id: Iee56131a15f9554c263406356456f65694515719
2015-11-24vcl: re-introduce idle handling.Michael Meeks
The idea here is that we should process 'idle' events - like re-paint after we have processed any OS messages - such as key/mouse input, window re-size events etc. The previous approach wasn't achieving this - it was processing a single idle event each time around the main-loop iteration; urk. Lubos implemented something -like- this, the vestiges of it need cleaning up and removing in: 06d731428ef6cf93c7333e8228bfb6088853b52f but it was disabled (most likely because it broke gtk in tdf#91727, which was itself broken by using silly values for timeouts in the scheduler (now fixed)) Tested on Windows, gtk, kde4, unx-generic. Change-Id: I7756bca874779c00f72b372cacb7745d0f189f66 Reviewed-on: https://gerrit.libreoffice.org/20158 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-24vcl: reduce maximum timeout to some sensible range.Michael Meeks
This fixes a bug with glib, where prepare of a source with such a large (max uint64) causes precision & wrap-around problems. Add assert to avoid recurrence. Also add a helpful user-visible source name in debug mode. Change-Id: I9e1eb41af9cc49f8bff88e07f04d4bc4d1877376 Reviewed-on: https://gerrit.libreoffice.org/20152 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-24vcl: remove UpdateStack concept.Michael Meeks
Change-Id: I6d9b7de7c57349bfb9c75a35e63bcf1eac172fd2 Reviewed-on: https://gerrit.libreoffice.org/20143 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-24Replace return boolean from DoYield with pleasant enumeration.Michael Meeks
Change-Id: I1b1f885b4d7916a18dfb2457a8e9af9a5b4ae6e4 Reviewed-on: https://gerrit.libreoffice.org/20138 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2015-11-10loplugin:nullptr (automatic rewrite)Stephan Bergmann
Change-Id: I05e89f9896170d4df3d1377549ea074f06b884a0
2015-09-08Ensure the scheduler can set longer timeouts.Michael Meeks
Regression from: 6d64d2f38d9f6c2f54e05675ecd0709eabf6d8ca. Also fix the low priority idle min timeout to 5ms. Change-Id: I26a6e89ef7fa173e64ee34f7a500157ba82b7198
2015-09-04Minor refactoring and cleanup of Scheduler and Timer.Ashod Nakashian
Members are now const-correct. Replaced compile-time constants with enum. Refactored common functions from Timer to Scheduler. Disabled timer-precision unittests as they misfire often. These changes are non-functional. Change-Id: I6bb3d9fc402cadd556d9063ed9a4888f114c73d7 Reviewed-on: https://gerrit.libreoffice.org/17977 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2015-07-08loplugin:unusedmethods vclNoel Grandin
Change-Id: I98b88ca3369a2c888fd63796e39d42376d513002
2015-06-15Revert "std::list for Scheduler"Stephan Bergmann
This reverts commit 1289d3c42af66990a2c8e5a7a38e51b6cd51c7eb, plus follow-ups 762e90ffa0cd5f85dadd9bad93391d105e60e418 "vcl: loplugin:pointertobool" and 863e5685dda88efd0bee3177a08eedffd4730e33 "Fix funny line-ends," as it causes memory corruption, see valgrind "make CppunitTest_sw_ooxmlexport4" output: > Invalid write of size 1 > Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:40) > Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128) > Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112) > SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53) > SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191) > SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307) > ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353) > Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377) > framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528) > framework::StatusIndicatorFactory::end(com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229) > framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70) > non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57) > writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531) > WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191) > non-virtual thunk to WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126) > SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271) > SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767) > SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859) > non-virtual thunk to SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810) > (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703) > non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615) > framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122) > framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383) > framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164) > framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:566) > non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:552) > unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50) > SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580) > SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219) > testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132) > CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166) > CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32) > (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77) > CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181) > CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64) > CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64) > CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23) > CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:47) > CppUnit::TestResult::runTest(CppUnit::Test*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:148) > CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:96) > Address 0x2c9ece48 is 40 bytes inside a block of size 104 free'd > operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) > (anonymous namespace)::ImpTimedRefDev::~ImpTimedRefDev() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:84) > std::default_delete<(anonymous namespace)::ImpTimedRefDev>::operator()((anonymous namespace)::ImpTimedRefDev*) const (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:76) > std::unique_ptr<(anonymous namespace)::ImpTimedRefDev, std::default_delete<(anonymous namespace)::ImpTimedRefDev> >::reset((anonymous namespace)::ImpTimedRefDev*) (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:344) > comphelper::unique_disposing_ptr<(anonymous namespace)::ImpTimedRefDev>::reset((anonymous namespace)::ImpTimedRefDev*) (/include/comphelper/unique_disposing_ptr.hxx:41) > (anonymous namespace)::ImpTimedRefDev::Invoke() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:93) > Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:39) > Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128) > Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112) > SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53) > SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191) > SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307) > ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353) > Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377) > framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528) > framework::StatusIndicatorFactory::end(com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229) > framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70) > non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57) > writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531) > WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191) > non-virtual thunk to WriterFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126) > SfxObjectShell::ImportFrom(SfxMedium&, com::sun::star::uno::Reference<com::sun::star::text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271) > SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767) > SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859) > non-virtual thunk to SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810) > (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703) > non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615) > framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122) > framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383) > framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164) > framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:566) > non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/framework/source/services/desktop.cxx:552) > unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50) > SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580) > SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219) > testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132) > CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166) > CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32) > (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77) > CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181) > CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64)
2015-06-12std::list for SchedulerJuergen Funk
Re-factor the scheduler to use std::list Because - ImplSchedulerData - remove: mbInScheduler, mnUpdateTime, mnUpdateStack that is scheduler stuff - this struct is only a container for the scheduler-list - UpdateMinPeriod - the scheduler is the pure-virtual-class then the idle-class must override this method - ImplDeInitScheduler(bool All=true) - this patch 2e29a518b04250b5f9cc9d0d77da3df076834d60 remove all scheduler tasks and the scheduler, but after that, the scheduler is using, then crash. With this fix, only delete the scheduler-list, but not the scheduler The next steps - split the scheduler from the scheduler-list-handling the scheduler-list-handling need a static class - remove the scheduler from the timer-handling staff Change-Id: I8d4d4f27b2bc9684a48c2afafd0b3edd0716c71d Reviewed-on: https://gerrit.libreoffice.org/16148 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>