cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / include / vcl / scheduler.hxx
blob0181e52c33d297e4aab8c1006aaa87fc04e1c80b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
30 friend class Task;
31 Scheduler() = delete;
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 );
39 static void Lock();
40 static void Unlock();
42 public:
43 static constexpr sal_uInt64 ImmediateTimeoutMs = 0;
44 static constexpr sal_uInt64 InfiniteTimeoutMs = SAL_MAX_UINT64;
46 static void ImplDeInitScheduler();
48 /**
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.
52 **/
53 static void CallbackTaskScheduling();
55 /**
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();
67 /**
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.
77 static void Wakeup();
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
88 IdlesLockGuard();
89 ~IdlesLockGuard();
93 #endif // INCLUDED_VCL_SCHEDULER_HXX
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */