1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_SCHEDULER_HXX
21 #define INCLUDED_VCL_SCHEDULER_HXX
23 #include <vcl/dllapi.h>
25 struct ImplSchedulerContext
;
27 class VCL_DLLPUBLIC Scheduler final
29 friend class SchedulerGuard
;
33 static inline void UpdateSystemTimer( ImplSchedulerContext
&rSchedCtx
,
34 sal_uInt64 nMinPeriod
,
35 bool bForce
, sal_uInt64 nTime
);
37 static void ImplStartTimer ( sal_uInt64 nMS
, bool bForce
, sal_uInt64 nTime
);
43 static constexpr sal_uInt64 ImmediateTimeoutMs
= 0;
44 static constexpr sal_uInt64 InfiniteTimeoutMs
= SAL_MAX_UINT64
;
46 static void ImplDeInitScheduler();
49 * System timer callback function, which processes one LO task
51 * Will restart the system timer, so it will process further tasks at the right time.
53 static void CallbackTaskScheduling();
56 * Process all events until none is pending
58 * This can busy-lock, if some task or system event always generates new
59 * events when being processed. Most time it's called in unit tests to
60 * process all pending events. Internally it just calls
61 * Application::Reschedule( true ) until it fails.
63 * @see Application::Reschedule
65 static void ProcessEventsToIdle();
68 * Wakes up the scheduler
70 * This doesn't handle any events! It just ensures the Scheduler is run as
71 * soon as possible by forcing the Scheduler timer to fire.
73 * Can be used for complex UpdateMinPeriod function, where the task is
74 * actually active but not ready and we want to skip the Task::Start()
75 * queue append for faster reaction.
79 /// Control the deterministic mode. In this mode, two subsequent runs of
80 /// LibreOffice fire about the same amount idles.
81 static void SetDeterministicMode(bool bDeterministic
);
82 /// Return the current state of deterministic mode.
83 static bool GetDeterministicMode();
85 // Makes sure that idles are not processed, until the guard is destroyed
86 struct VCL_DLLPUBLIC IdlesLockGuard final
93 #endif // INCLUDED_VCL_SCHEDULER_HXX
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */