LibreOffice Module vcl (master)  1
task.hxx
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 #ifndef INCLUDED_VCL_TASK_HXX
21 #define INCLUDED_VCL_TASK_HXX
22 
23 #include <vcl/dllapi.h>
24 
25 struct ImplSchedulerData;
26 
27 enum class TaskPriority
28 {
29  HIGHEST,
30  DEFAULT,
31  HIGH_IDLE,
32  RESIZE,
33  REPAINT,
34  POST_PAINT,
35  DEFAULT_IDLE,
36  LOWEST
37 };
38 
39 #define PRIO_COUNT (static_cast<int>(TaskPriority::LOWEST) + 1)
40 
42 {
43  friend class Scheduler;
44  friend struct ImplSchedulerData;
45 
49  bool mbActive;
50  bool mbStatic;
51 
52 protected:
53  static void StartTimer( sal_uInt64 nMS );
54 
55  const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; }
56 
57  virtual void SetDeletionFlags();
58 
71  virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const = 0;
72 
73 public:
74  Task( const sal_Char *pDebugName );
75  Task( const Task& rTask );
76  virtual ~Task() COVERITY_NOEXCEPT_FALSE;
77  Task& operator=( const Task& rTask );
78 
79  void SetPriority(TaskPriority ePriority);
80  TaskPriority GetPriority() const { return mePriority; }
81 
82  void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; }
83  const char *GetDebugName() const { return mpDebugName; }
84 
85  // Call handler
86  virtual void Invoke() = 0;
87 
88  virtual void Start();
89  void Stop();
90 
91  bool IsActive() const { return mbActive; }
92 
99  void SetStatic() { mbStatic = true; }
100  bool IsStatic() const { return mbStatic; }
101 };
102 
103 #endif // INCLUDED_VCL_TASK_HXX
104 
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool mbStatic
Is a static object.
Definition: task.hxx:50
Resize runs before repaint, so we won't paint twice.
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Important idle events to be run before processing drawing events.
TaskPriority mePriority
Task priority.
Everything running directly after painting.
bool IsActive() const
Definition: task.hxx:91
Default priority used, e.g. the default timer priority.
ImplSchedulerData * mpSchedulerData
Pointer to the element in scheduler list.
Definition: task.hxx:46
char sal_Char
TaskPriority mePriority
Task priority.
Definition: task.hxx:48
const sal_Char * mpDebugName
Useful for debugging.
Definition: task.hxx:47
void SetStatic()
This function must be called for static tasks, so the Task destructor ignores the SchedulerMutex...
Definition: task.hxx:99
All repaint events should go in here.
bool mbActive
Currently in the scheduler.
Definition: task.hxx:49
Default idle priority.
bool IsStatic() const
Definition: task.hxx:100
TaskPriority
Definition: task.hxx:27
These events should run very fast!
aCursorMoveIdle Stop()
Low, very idle cleanup tasks.
Definition: task.hxx:41
const char * GetDebugName() const
Definition: task.hxx:83
const ImplSchedulerData * GetSchedulerData() const
Definition: task.hxx:55
void SetDebugName(const sal_Char *pDebugName)
Definition: task.hxx:82