Line data Source code
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 : #ifndef INCLUDED_VCL_SCHEDULER_HXX
21 : #define INCLUDED_VCL_SCHEDULER_HXX
22 :
23 : #include <vcl/dllapi.h>
24 :
25 : struct ImplSVData;
26 : class Scheduler;
27 : struct ImplSchedulerData
28 : {
29 : ImplSchedulerData* mpNext; // Pointer to the next element in list
30 : Scheduler* mpScheduler; // Pointer to VCL Scheduler instance
31 : bool mbDelete; // Destroy this scheduler?
32 : bool mbInScheduler; // Scheduler currently processed?
33 : sal_uInt64 mnUpdateTime; // Last Update Time
34 : sal_uInt32 mnUpdateStack; // Update Stack
35 :
36 : void Invoke();
37 :
38 : static ImplSchedulerData *GetMostImportantTask( bool bTimer );
39 : };
40 :
41 : enum class SchedulerPriority {
42 : HIGHEST = 0,
43 : HIGH = 1,
44 : RESIZE = 2,
45 : REPAINT = 3,
46 : MEDIUM = 3,
47 : LOW = 4,
48 : LOWER = 5,
49 : LOWEST = 6
50 : };
51 :
52 : class VCL_DLLPUBLIC Scheduler
53 : {
54 : protected:
55 : ImplSchedulerData* mpSchedulerData; /// Pointer to element in scheduler list
56 : const sal_Char *mpDebugName; /// Useful for debugging
57 : SchedulerPriority mePriority; /// Scheduler priority
58 : bool mbActive; /// Currently in the scheduler
59 :
60 : friend struct ImplSchedulerData;
61 : virtual void SetDeletionFlags();
62 : virtual bool ReadyForSchedule( bool bTimer ) = 0;
63 : virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) = 0;
64 :
65 : public:
66 : Scheduler( const sal_Char *pDebugName = NULL );
67 : Scheduler( const Scheduler& rScheduler );
68 : virtual ~Scheduler();
69 :
70 : void SetPriority( SchedulerPriority ePriority );
71 18156158 : SchedulerPriority GetPriority() const { return mePriority; }
72 :
73 13996 : void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; }
74 : const sal_Char *GetDebugName() { return mpDebugName; }
75 :
76 : // Call handler
77 : virtual void Invoke() = 0;
78 :
79 : virtual void Start();
80 : void Stop();
81 :
82 38613050 : bool IsActive() const { return mbActive; }
83 : void SetInActive() { mbActive = false; }
84 :
85 : Scheduler& operator=( const Scheduler& rScheduler );
86 : static void ImplDeInitScheduler();
87 :
88 : // Process one pending Timer with highhest priority
89 : static void CallbackTaskScheduling( bool ignore );
90 : /// Process one pending task ahead of time with highhest priority.
91 : static void ProcessTaskScheduling( bool bTimer );
92 : };
93 :
94 : #endif // INCLUDED_VCL_SCHEDULER_HXX
95 :
96 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|