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>
27 struct ImplSchedulerData
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
38 static ImplSchedulerData
*GetMostImportantTask( bool bTimer
);
41 enum class SchedulerPriority
{
52 class VCL_DLLPUBLIC Scheduler
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
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;
66 Scheduler( const sal_Char
*pDebugName
= NULL
);
67 Scheduler( const Scheduler
& rScheduler
);
70 void SetPriority( SchedulerPriority ePriority
);
71 SchedulerPriority
GetPriority() const { return mePriority
; }
73 void SetDebugName( const sal_Char
*pDebugName
) { mpDebugName
= pDebugName
; }
74 const sal_Char
*GetDebugName() { return mpDebugName
; }
77 virtual void Invoke() = 0;
82 bool IsActive() const { return mbActive
; }
83 void SetInActive() { mbActive
= false; }
85 Scheduler
& operator=( const Scheduler
& rScheduler
);
86 static void ImplDeInitScheduler();
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
);
94 #endif // INCLUDED_VCL_SCHEDULER_HXX
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */