LibreOffice Module vcl (master) 1
scheduler.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <cassert>
23#include <cstdlib>
24#include <exception>
25#include <typeinfo>
26
27#include <com/sun/star/uno/Exception.hpp>
28#include <sal/log.hxx>
29#include <sal/types.h>
30#include <svdata.hxx>
31#include <tools/time.hxx>
32#include <tools/debug.hxx>
35#include <vcl/TaskStopwatch.hxx>
36#include <vcl/scheduler.hxx>
37#include <vcl/idle.hxx>
38#include <saltimer.hxx>
39#include <salinst.hxx>
41#include <schedulerimpl.hxx>
42
43namespace {
44
45template< typename charT, typename traits >
46std::basic_ostream<charT, traits> & operator <<(
47 std::basic_ostream<charT, traits> & stream, const Task& task )
48{
49 stream << "a: " << task.IsActive() << " p: " << static_cast<int>(task.GetPriority());
50 const char *name = task.GetDebugName();
51 if( nullptr == name )
52 return stream << " (nullptr)";
53 else
54 return stream << " " << name;
55}
56
64template< typename charT, typename traits >
65std::basic_ostream<charT, traits> & operator <<(
66 std::basic_ostream<charT, traits> & stream, const Timer& timer )
67{
68 bool bIsIdle = (dynamic_cast<const Idle*>( &timer ) != nullptr);
69 stream << (bIsIdle ? "Idle " : "Timer")
70 << " a: " << timer.IsActive() << " p: " << static_cast<int>(timer.GetPriority());
71 const char *name = timer.GetDebugName();
72 if ( nullptr == name )
73 stream << " (nullptr)";
74 else
75 stream << " " << name;
76 if ( !bIsIdle )
77 stream << " " << timer.GetTimeout() << "ms";
78 stream << " (" << &timer << ")";
79 return stream;
80}
81
82template< typename charT, typename traits >
83std::basic_ostream<charT, traits> & operator <<(
84 std::basic_ostream<charT, traits> & stream, const Idle& idle )
85{
86 return stream << static_cast<const Timer*>( &idle );
87}
88
89template< typename charT, typename traits >
90std::basic_ostream<charT, traits> & operator <<(
91 std::basic_ostream<charT, traits> & stream, const ImplSchedulerData& data )
92{
93 stream << " i: " << data.mbInScheduler;
94 return stream;
95}
96
97} // end anonymous namespace
98
100
102{
103 ImplSVData* pSVData = ImplGetSVData();
104 assert( pSVData != nullptr );
105 ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
106
108
109 SchedulerGuard aSchedulerGuard;
110
111 int nTaskPriority = 0;
112#if OSL_DEBUG_LEVEL > 0
113 sal_uInt32 nTasks = 0;
114 for (nTaskPriority = 0; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
115 {
116 ImplSchedulerData* pSchedulerData = rSchedCtx.mpFirstSchedulerData[nTaskPriority];
117 while ( pSchedulerData )
118 {
119 ++nTasks;
120 pSchedulerData = pSchedulerData->mpNext;
121 }
122 }
123 SAL_INFO( "vcl.schedule.deinit",
124 "DeInit the scheduler - pending tasks: " << nTasks );
125
126 // clean up all the sfx::SfxItemDisruptor_Impl Idles
127 Unlock();
129 Lock();
130#endif
131 rSchedCtx.mbActive = false;
132
133 assert( nullptr == rSchedCtx.mpSchedulerStack );
134
135 if (rSchedCtx.mpSalTimer) rSchedCtx.mpSalTimer->Stop();
136 delete rSchedCtx.mpSalTimer;
137 rSchedCtx.mpSalTimer = nullptr;
138
139#if OSL_DEBUG_LEVEL > 0
140 sal_uInt32 nActiveTasks = 0, nIgnoredTasks = 0;
141#endif
142 nTaskPriority = 0;
143 ImplSchedulerData* pSchedulerData = nullptr;
144
145next_priority:
146 pSchedulerData = rSchedCtx.mpFirstSchedulerData[nTaskPriority];
147 while ( pSchedulerData )
148 {
149 Task *pTask = pSchedulerData->mpTask;
150 if ( pTask )
151 {
152 if ( pTask->mbActive )
153 {
154#if OSL_DEBUG_LEVEL > 0
155 const char *sIgnored = "";
156 ++nActiveTasks;
157 // TODO: shutdown these timers before Scheduler de-init
158 // TODO: remove Task from static object
159 if ( pTask->GetDebugName() && ( false
160 || !strcmp( pTask->GetDebugName(), "desktop::Desktop m_firstRunTimer" )
161 || !strcmp( pTask->GetDebugName(), "DrawWorkStartupTimer" )
162 || !strcmp( pTask->GetDebugName(), "editeng::ImpEditEngine aOnlineSpellTimer" )
163 || !strcmp( pTask->GetDebugName(), "sc ScModule IdleTimer" )
164 || !strcmp( pTask->GetDebugName(), "sd::CacheConfiguration maReleaseTimer" )
165 || !strcmp( pTask->GetDebugName(), "svtools::GraphicCache maReleaseTimer" )
166 || !strcmp( pTask->GetDebugName(), "svtools::GraphicObject mpSwapOutTimer" )
167 || !strcmp( pTask->GetDebugName(), "svx OLEObjCache pTimer UnloadCheck" )
168 || !strcmp( pTask->GetDebugName(), "vcl SystemDependentDataBuffer aSystemDependentDataBuffer" )
169 ))
170 {
171 sIgnored = " (ignored)";
172 ++nIgnoredTasks;
173 }
174 const Timer *timer = dynamic_cast<Timer*>( pTask );
175 if ( timer )
176 SAL_WARN( "vcl.schedule.deinit", "DeInit task: " << *timer << sIgnored );
177 else
178 SAL_WARN( "vcl.schedule.deinit", "DeInit task: " << *pTask << sIgnored );
179#endif
180 pTask->mbActive = false;
181 }
182 pTask->mpSchedulerData = nullptr;
183 pTask->SetStatic();
184 }
185 ImplSchedulerData* pDeleteSchedulerData = pSchedulerData;
186 pSchedulerData = pSchedulerData->mpNext;
187 delete pDeleteSchedulerData;
188 }
189
190 ++nTaskPriority;
191 if (nTaskPriority < PRIO_COUNT)
192 goto next_priority;
193
194#if OSL_DEBUG_LEVEL > 0
195 SAL_INFO( "vcl.schedule.deinit", "DeInit the scheduler - finished" );
196 SAL_WARN_IF( 0 != nActiveTasks, "vcl.schedule.deinit", "DeInit active tasks: "
197 << nActiveTasks << " (ignored: " << nIgnoredTasks << ")" );
198// assert( nIgnoredTasks == nActiveTasks );
199#endif
200
201 for (nTaskPriority = 0; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
202 {
203 rSchedCtx.mpFirstSchedulerData[nTaskPriority] = nullptr;
204 rSchedCtx.mpLastSchedulerData[nTaskPriority] = nullptr;
205 }
207}
208
210{
211 ImplSVData* pSVData = ImplGetSVData();
212 assert( pSVData != nullptr );
213 pSVData->maSchedCtx.maMutex.lock();
214}
215
217{
218 ImplSVData* pSVData = ImplGetSVData();
219 assert( pSVData != nullptr );
220 pSVData->maSchedCtx.maMutex.unlock();
221}
222
230void Scheduler::ImplStartTimer(sal_uInt64 nMS, bool bForce, sal_uInt64 nTime)
231{
232 ImplSVData* pSVData = ImplGetSVData();
233 ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
234 if ( !rSchedCtx.mbActive )
235 return;
236
237 if (!rSchedCtx.mpSalTimer)
238 {
239 rSchedCtx.mnTimerStart = 0;
241 rSchedCtx.mpSalTimer = pSVData->mpDefInst->CreateSalTimer();
243 }
244
245 assert(SAL_MAX_UINT64 - nMS >= nTime);
246
247 sal_uInt64 nProposedTimeout = nTime + nMS;
248 sal_uInt64 nCurTimeout = ( rSchedCtx.mnTimerPeriod == InfiniteTimeoutMs )
249 ? SAL_MAX_UINT64 : rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod;
250
251 // Only if smaller timeout, to avoid skipping.
252 // Force instant wakeup on 0ms, if the previous period was not 0ms
253 if (bForce || nProposedTimeout < nCurTimeout || (!nMS && rSchedCtx.mnTimerPeriod))
254 {
255 SAL_INFO( "vcl.schedule", " Starting scheduler system timer (" << nMS << "ms)" );
256 rSchedCtx.mnTimerStart = nTime;
257 rSchedCtx.mnTimerPeriod = nMS;
258 rSchedCtx.mpSalTimer->Start( nMS );
259 }
260}
261
262static bool g_bDeterministicMode = false;
263
264void Scheduler::SetDeterministicMode(bool bDeterministic)
265{
266 g_bDeterministicMode = bDeterministic;
267}
268
270{
272}
273
275 const sal_uInt64 nMinPeriod,
276 const bool bForce, const sal_uInt64 nTime )
277{
278 if ( InfiniteTimeoutMs == nMinPeriod )
279 {
280 SAL_INFO("vcl.schedule", " Stopping system timer");
281 if ( rSchedCtx.mpSalTimer )
282 rSchedCtx.mpSalTimer->Stop();
283 rSchedCtx.mnTimerPeriod = nMinPeriod;
284 }
285 else
286 Scheduler::ImplStartTimer( nMinPeriod, bForce, nTime );
287}
288
290 ImplSchedulerData * const pSchedulerData)
291{
292 assert(pSchedulerData->mpTask);
293 pSchedulerData->mePriority = pSchedulerData->mpTask->GetPriority();
294 pSchedulerData->mpNext = nullptr;
295
296 const int nTaskPriority = static_cast<int>(pSchedulerData->mePriority);
297 if (!rSchedCtx.mpLastSchedulerData[nTaskPriority])
298 {
299 rSchedCtx.mpFirstSchedulerData[nTaskPriority] = pSchedulerData;
300 rSchedCtx.mpLastSchedulerData[nTaskPriority] = pSchedulerData;
301 }
302 else
303 {
304 rSchedCtx.mpLastSchedulerData[nTaskPriority]->mpNext = pSchedulerData;
305 rSchedCtx.mpLastSchedulerData[nTaskPriority] = pSchedulerData;
306 }
307}
308
310 ImplSchedulerContext &rSchedCtx, ImplSchedulerData * const pPrevSchedulerData,
311 const ImplSchedulerData * const pSchedulerData, const int nTaskPriority)
312{
313 assert( pSchedulerData );
314 if ( pPrevSchedulerData )
315 assert( pPrevSchedulerData->mpNext == pSchedulerData );
316 else
317 assert(rSchedCtx.mpFirstSchedulerData[nTaskPriority] == pSchedulerData);
318
319 ImplSchedulerData * const pSchedulerDataNext = pSchedulerData->mpNext;
320 if ( pPrevSchedulerData )
321 pPrevSchedulerData->mpNext = pSchedulerDataNext;
322 else
323 rSchedCtx.mpFirstSchedulerData[nTaskPriority] = pSchedulerDataNext;
324 if ( !pSchedulerDataNext )
325 rSchedCtx.mpLastSchedulerData[nTaskPriority] = pPrevSchedulerData;
326 return pSchedulerDataNext;
327}
328
330{
331 ImplSVData *pSVData = ImplGetSVData();
332 ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
333
335
336 SchedulerGuard aSchedulerGuard;
337 if ( !rSchedCtx.mbActive || InfiniteTimeoutMs == rSchedCtx.mnTimerPeriod )
338 return;
339
340 sal_uInt64 nTime = tools::Time::GetSystemTicks();
341 // Allow for decimals, so subtract in the compare (needed at least on iOS)
342 if ( nTime < rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod -1)
343 {
344 int nSleep = rSchedCtx.mnTimerStart + rSchedCtx.mnTimerPeriod - nTime;
345 UpdateSystemTimer(rSchedCtx, nSleep, true, nTime);
346 return;
347 }
348
349 ImplSchedulerData* pSchedulerData = nullptr;
350 ImplSchedulerData* pPrevSchedulerData = nullptr;
351 ImplSchedulerData *pMostUrgent = nullptr;
352 ImplSchedulerData *pPrevMostUrgent = nullptr;
353 int nMostUrgentPriority = 0;
354 sal_uInt64 nMinPeriod = InfiniteTimeoutMs;
355 sal_uInt64 nReadyPeriod = InfiniteTimeoutMs;
356 unsigned nTasks = 0;
357 int nTaskPriority = 0;
358
359 for (; nTaskPriority < PRIO_COUNT; ++nTaskPriority)
360 {
361 // Related: tdf#152703 Eliminate potential blocking during live resize
362 // Only higher priority tasks need to be fired to redraw the window
363 // so skip firing potentially long-running tasks, such as the Writer
364 // idle layout timer, when a window is in live resize
365 if ( ImplGetSVData()->mpWinData->mbIsLiveResize && nTaskPriority == static_cast<int>(TaskPriority::LOWEST) )
366 continue;
367
368 pSchedulerData = rSchedCtx.mpFirstSchedulerData[nTaskPriority];
369 pPrevSchedulerData = nullptr;
370 while (pSchedulerData)
371 {
372 ++nTasks;
373 const Timer *timer = dynamic_cast<Timer*>( pSchedulerData->mpTask );
374 if ( timer )
375 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
376 << pSchedulerData << " " << *pSchedulerData << " " << *timer );
377 else if ( pSchedulerData->mpTask )
378 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
379 << pSchedulerData << " " << *pSchedulerData
380 << " " << *pSchedulerData->mpTask );
381 else
382 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
383 << pSchedulerData << " " << *pSchedulerData << " (to be deleted)" );
384
385 // Should the Task be released from scheduling?
386 assert(!pSchedulerData->mbInScheduler);
387 if (!pSchedulerData->mpTask || !pSchedulerData->mpTask->IsActive())
388 {
389 ImplSchedulerData * const pSchedulerDataNext =
390 DropSchedulerData(rSchedCtx, pPrevSchedulerData, pSchedulerData, nTaskPriority);
391 if ( pSchedulerData->mpTask )
392 pSchedulerData->mpTask->mpSchedulerData = nullptr;
393 delete pSchedulerData;
394 pSchedulerData = pSchedulerDataNext;
395 continue;
396 }
397
398 assert(pSchedulerData->mpTask);
399 if (pSchedulerData->mpTask->IsActive())
400 {
401 nReadyPeriod = pSchedulerData->mpTask->UpdateMinPeriod( nTime );
402 if (ImmediateTimeoutMs == nReadyPeriod)
403 {
404 if (!pMostUrgent)
405 {
406 pPrevMostUrgent = pPrevSchedulerData;
407 pMostUrgent = pSchedulerData;
408 nMostUrgentPriority = nTaskPriority;
409 }
410 else
411 {
412 nMinPeriod = ImmediateTimeoutMs;
413 break;
414 }
415 }
416 else if (nMinPeriod > nReadyPeriod)
417 nMinPeriod = nReadyPeriod;
418 }
419
420 pPrevSchedulerData = pSchedulerData;
421 pSchedulerData = pSchedulerData->mpNext;
422 }
423
424 if (ImmediateTimeoutMs == nMinPeriod)
425 break;
426 }
427
428 if (InfiniteTimeoutMs != nMinPeriod)
429 SAL_INFO("vcl.schedule",
430 "Calculated minimum timeout as " << nMinPeriod << " of " << nTasks << " tasks");
431 UpdateSystemTimer(rSchedCtx, nMinPeriod, true, nTime);
432
433 if ( !pMostUrgent )
434 return;
435
436 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
437 << pMostUrgent << " invoke-in " << *pMostUrgent->mpTask );
438
439 Task *pTask = pMostUrgent->mpTask;
440
441 comphelper::ProfileZone aZone( pTask->GetDebugName() );
442
443 assert(!pMostUrgent->mbInScheduler);
444 pMostUrgent->mbInScheduler = true;
445
446 // always push the stack, as we don't traverse the whole list to push later
447 DropSchedulerData(rSchedCtx, pPrevMostUrgent, pMostUrgent, nMostUrgentPriority);
448 pMostUrgent->mpNext = rSchedCtx.mpSchedulerStack;
449 rSchedCtx.mpSchedulerStack = pMostUrgent;
450 rSchedCtx.mpSchedulerStackTop = pMostUrgent;
451
452 bool bIsHighPriorityIdle = pMostUrgent->mePriority >= TaskPriority::HIGH_IDLE;
453
454 // invoke the task
455 Unlock();
456
457 // Delay invoking tasks with idle priorities as long as there are user input or repaint events
458 // in the OS event queue. This will often effectively compress such events and repaint only
459 // once at the end, improving performance in cases such as repeated zooming with a complex document.
460 bool bDelayInvoking = bIsHighPriorityIdle &&
462
463 /*
464 * Current policy is that scheduler tasks aren't allowed to throw an exception.
465 * Because otherwise the exception is caught somewhere totally unrelated.
466 * TODO Ideally we could capture a proper backtrace and feed this into breakpad,
467 * which is do-able, but requires writing some assembly.
468 * See also SalUserEventList::DispatchUserEvents
469 */
470 try
471 {
472 if (bDelayInvoking)
473 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks()
474 << " idle priority task " << pTask->GetDebugName()
475 << " delayed, system events pending" );
476 else
477 {
478 // prepare Scheduler object for deletion after handling
479 pTask->SetDeletionFlags();
480 pTask->Invoke();
481 }
482 }
483 catch (css::uno::Exception&)
484 {
485 TOOLS_WARN_EXCEPTION("vcl.schedule", "Uncaught");
486 std::abort();
487 }
488 catch (std::exception& e)
489 {
490 SAL_WARN("vcl.schedule", "Uncaught " << typeid(e).name() << " " << e.what());
491 std::abort();
492 }
493 catch (...)
494 {
495 SAL_WARN("vcl.schedule", "Uncaught exception during Task::Invoke()!");
496 std::abort();
497 }
498 Lock();
499
500 assert(pMostUrgent->mbInScheduler);
501 pMostUrgent->mbInScheduler = false;
502
503 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " "
504 << pMostUrgent << " invoke-out" );
505
506 // pop the scheduler stack
507 pSchedulerData = rSchedCtx.mpSchedulerStack;
508 assert(pSchedulerData == pMostUrgent);
509 rSchedCtx.mpSchedulerStack = pSchedulerData->mpNext;
510
511 // coverity[check_after_deref : FALSE] - pMostUrgent->mpTask is initially pMostUrgent->mpTask, but Task::Invoke can clear it
512 const bool bTaskAlive = pMostUrgent->mpTask && pMostUrgent->mpTask->IsActive();
513 if (!bTaskAlive)
514 {
515 if (pMostUrgent->mpTask)
516 pMostUrgent->mpTask->mpSchedulerData = nullptr;
517 delete pMostUrgent;
518 }
519 else
520 AppendSchedulerData(rSchedCtx, pMostUrgent);
521
522 // this just happens for nested calls, which renders all accounting
523 // invalid, so we just enforce a rescheduling!
524 if (rSchedCtx.mpSchedulerStackTop != pSchedulerData)
525 {
526 UpdateSystemTimer( rSchedCtx, ImmediateTimeoutMs, true,
528 }
529 else if (bTaskAlive)
530 {
531 pMostUrgent->mnUpdateTime = nTime;
532 nReadyPeriod = pMostUrgent->mpTask->UpdateMinPeriod( nTime );
533 if ( nMinPeriod > nReadyPeriod )
534 nMinPeriod = nReadyPeriod;
535 UpdateSystemTimer( rSchedCtx, nMinPeriod, false, nTime );
536 }
537}
538
540{
542}
543
544void Task::StartTimer( sal_uInt64 nMS )
545{
547}
548
550{
551 mbActive = false;
552}
553
554void Task::Start(const bool bStartTimer)
555{
556 ImplSVData *const pSVData = ImplGetSVData();
557 ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
558
559 SchedulerGuard aSchedulerGuard;
560 if ( !rSchedCtx.mbActive )
561 return;
562
563 // is the task scheduled in the correct priority queue?
564 // if not we have to get a new data object, as we don't want to traverse
565 // the whole list to move the data to the correct list, as the task list
566 // is just single linked.
567 // Task priority doesn't change that often AFAIK, or we might need to
568 // start caching ImplSchedulerData objects.
570 {
571 mpSchedulerData->mpTask = nullptr;
572 mpSchedulerData = nullptr;
573 }
574 mbActive = true;
575
576 if ( !mpSchedulerData )
577 {
578 // insert Task
579 ImplSchedulerData* pSchedulerData = new ImplSchedulerData;
580 pSchedulerData->mpTask = this;
581 pSchedulerData->mbInScheduler = false;
582 // mePriority is set in AppendSchedulerData
583 mpSchedulerData = pSchedulerData;
584
585 AppendSchedulerData( rSchedCtx, pSchedulerData );
586 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks()
587 << " " << mpSchedulerData << " added " << *this );
588 }
589 else
590 SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks()
591 << " " << mpSchedulerData << " restarted " << *this );
592
594
595 if (bStartTimer)
597}
598
600{
602 << " " << mpSchedulerData << " stopped " << *this );
603 mbActive = false;
604}
605
607{
608 // you don't actually need to call Stop() before but Start() after, but we
609 // can't check that and don't know when Start() should be called.
610 SAL_WARN_IF(mpSchedulerData && mbActive, "vcl.schedule",
611 "Stop the task before changing the priority, as it will just "
612 "change after the task was scheduled with the old prio!");
613 mePriority = ePriority;
614}
615
616Task& Task::operator=( const Task& rTask )
617{
618 if(this == &rTask)
619 return *this;
620
621 if ( IsActive() )
622 Stop();
623
624 mbActive = false;
625 mePriority = rTask.mePriority;
626
627 if ( rTask.IsActive() )
628 Start();
629
630 return *this;
631}
632
633Task::Task( const char *pDebugName )
634 : mpSchedulerData( nullptr )
635 , mpDebugName( pDebugName )
636 , mePriority( TaskPriority::DEFAULT )
637 , mbActive( false )
638 , mbStatic( false )
639{
640 assert(mpDebugName);
641}
642
643Task::Task( const Task& rTask )
644 : mpSchedulerData( nullptr )
645 , mpDebugName( rTask.mpDebugName )
646 , mePriority( rTask.mePriority )
647 , mbActive( false )
648 , mbStatic( false )
649{
650 assert(mpDebugName);
651 if ( rTask.IsActive() )
652 Start();
653}
654
655Task::~Task() COVERITY_NOEXCEPT_FALSE
656{
657 if ( !IsStatic() )
658 {
659 SchedulerGuard aSchedulerGuard;
660 if ( mpSchedulerData )
661 mpSchedulerData->mpTask = nullptr;
662 }
663 else
664 assert(nullptr == mpSchedulerData || utl::ConfigManager::IsFuzzing());
665}
666
667/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::ostream & operator<<(std::ostream &rStrm, const glm::mat4 &rMatrix)
static bool AnyInput(VclInputFlags nType=VCL_INPUT_ANY)
Determine if there are any pending input events.
Definition: svapp.cxx:500
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:35
virtual SalTimer * CreateSalTimer()=0
void SetCallback(SALTIMERPROC pProc)
Definition: saltimer.hxx:46
virtual void Start(sal_uInt64 nMS)=0
virtual void Stop()=0
static void SetDeterministicMode(bool bDeterministic)
Control the deterministic mode.
Definition: scheduler.cxx:264
static void Lock()
Definition: scheduler.cxx:209
static bool GetDeterministicMode()
Return the current state of deterministic mode.
Definition: scheduler.cxx:269
static void ImplDeInitScheduler()
Definition: scheduler.cxx:101
static void CallbackTaskScheduling()
System timer callback function, which processes one LO task.
Definition: scheduler.cxx:329
static constexpr sal_uInt64 InfiniteTimeoutMs
Definition: scheduler.hxx:44
static constexpr sal_uInt64 ImmediateTimeoutMs
Definition: scheduler.hxx:43
static void Wakeup()
Wakes up the scheduler.
Definition: scheduler.cxx:539
static void UpdateSystemTimer(ImplSchedulerContext &rSchedCtx, sal_uInt64 nMinPeriod, bool bForce, sal_uInt64 nTime)
Definition: scheduler.cxx:274
static void ProcessEventsToIdle()
Process all events until none is pending.
Definition: svapp.cxx:379
static void Unlock()
Definition: scheduler.cxx:216
static void ImplStartTimer(sal_uInt64 nMS, bool bForce, sal_uInt64 nTime)
Start a new timer if we need to for nMS duration.
Definition: scheduler.cxx:230
static constexpr unsigned int nDefaultTimeSlice
static unsigned int m_nTimeSlice
Definition: task.hxx:43
bool IsActive() const
Definition: task.hxx:101
virtual sal_uInt64 UpdateMinPeriod(sal_uInt64 nTimeNow) const =0
How long (in MS) until the Task is ready to be dispatched?
bool mbActive
Currently in the scheduler.
Definition: task.hxx:50
bool IsStatic() const
Definition: task.hxx:110
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:606
void Stop()
Definition: scheduler.cxx:599
virtual ~Task() COVERITY_NOEXCEPT_FALSE
Definition: scheduler.cxx:655
const char * GetDebugName() const
Definition: task.hxx:82
const char * mpDebugName
Useful for debugging.
Definition: task.hxx:48
ImplSchedulerData * mpSchedulerData
Pointer to the element in scheduler list.
Definition: task.hxx:47
TaskPriority mePriority
Task priority.
Definition: task.hxx:49
Task & operator=(const Task &rTask)
Definition: scheduler.cxx:616
TaskPriority GetPriority() const
Definition: task.hxx:80
virtual void Start(bool bStartTimer=true)
Schedules the task for execution.
Definition: scheduler.cxx:554
friend struct ImplSchedulerData
Definition: task.hxx:45
void SetStatic()
This function must be called for static tasks, so the Task destructor ignores the scheduler mutex,...
Definition: task.hxx:109
Task(const char *pDebugName)
Definition: scheduler.cxx:633
virtual void Invoke()=0
virtual void SetDeletionFlags()
Definition: scheduler.cxx:549
static void StartTimer(sal_uInt64 nMS)
Definition: scheduler.cxx:544
Definition: timer.hxx:27
sal_uInt64 GetTimeout() const
Definition: timer.hxx:60
static sal_uInt64 GetSystemTicks()
static bool IsFuzzing()
#define DBG_TESTSOLARMUTEX()
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XOutputStream > stream
const char * name
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
static void AppendSchedulerData(ImplSchedulerContext &rSchedCtx, ImplSchedulerData *const pSchedulerData)
Definition: scheduler.cxx:289
static bool g_bDeterministicMode
Definition: scheduler.cxx:262
static ImplSchedulerData * DropSchedulerData(ImplSchedulerContext &rSchedCtx, ImplSchedulerData *const pPrevSchedulerData, const ImplSchedulerData *const pSchedulerData, const int nTaskPriority)
Definition: scheduler.cxx:309
bool mbActive
ImplSchedulerContext maSchedCtx
Definition: svdata.hxx:396
SalInstance * mpDefInst
Definition: svdata.hxx:389
ImplSchedulerData * mpLastSchedulerData[PRIO_COUNT]
last item of each mpFirstSchedulerData list
Definition: svdata.hxx:373
bool mbActive
is the scheduler active?
Definition: svdata.hxx:381
ImplSchedulerData * mpFirstSchedulerData[PRIO_COUNT]
list of all active tasks per priority
Definition: svdata.hxx:372
ImplSchedulerData * mpSchedulerStack
stack of invoked tasks
Definition: svdata.hxx:374
SalTimer * mpSalTimer
interface to sal event loop / system timer
Definition: svdata.hxx:376
sal_uInt64 mnTimerStart
start time of the timer
Definition: svdata.hxx:377
std::mutex maMutex
the "scheduler mutex" (see vcl/README.scheduler)
Definition: svdata.hxx:379
sal_uInt64 mnTimerPeriod
current timer period
Definition: svdata.hxx:378
ImplSchedulerData * mpSchedulerStackTop
top most stack entry to detect needed rescheduling during pop
Definition: svdata.hxx:375
sal_uInt64 mnUpdateTime
Last Update Time.
ImplSchedulerData * mpNext
Pointer to the next element in list.
bool mbInScheduler
Is the Task currently processed / on the stack?
Task * mpTask
Pointer to VCL Task instance.
TaskPriority mePriority
Task priority.
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
#define PRIO_COUNT
Definition: task.hxx:40
TaskPriority
Definition: task.hxx:28
@ LOWEST
Low, very idle cleanup tasks.
@ HIGH_IDLE
Important idle events to be run before processing drawing events.
#define SAL_MAX_UINT64