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
26
27enum class TaskPriority
28{
29 HIGHEST,
30 DEFAULT,
31 // Input from the OS event queue is processed before HIGH_IDLE tasks.
32 HIGH_IDLE,
33 RESIZE,
34 REPAINT,
37 LOWEST
38};
39
40#define PRIO_COUNT (static_cast<int>(TaskPriority::LOWEST) + 1)
41
43{
44 friend class Scheduler;
45 friend struct ImplSchedulerData;
46
48 const char *mpDebugName;
50 bool mbActive;
51 bool mbStatic;
52
53protected:
54 static void StartTimer( sal_uInt64 nMS );
55
56 const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; }
57
58 virtual void SetDeletionFlags();
59
71 virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nTimeNow ) const = 0;
72
73public:
74 Task( const 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 const char *GetDebugName() const { return mpDebugName; }
83
84 // Call handler
85 virtual void Invoke() = 0;
86
98 virtual void Start(bool bStartTimer = true);
99 void Stop();
100
101 bool IsActive() const { return mbActive; }
102
109 void SetStatic() { mbStatic = true; }
110 bool IsStatic() const { return mbStatic; }
111};
112
113#endif // INCLUDED_VCL_TASK_HXX
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: task.hxx:43
bool IsActive() const
Definition: task.hxx:101
virtual sal_uInt64 UpdateMinPeriod(sal_uInt64 nTimeNow) const =0
How long (in MS) until the Task is ready to be dispatched?
bool mbActive
Currently in the scheduler.
Definition: task.hxx:50
bool IsStatic() const
Definition: task.hxx:110
bool mbStatic
Is a static object.
Definition: task.hxx:51
const ImplSchedulerData * GetSchedulerData() const
Definition: task.hxx:56
const char * GetDebugName() const
Definition: task.hxx:82
const char * mpDebugName
Useful for debugging.
Definition: task.hxx:48
ImplSchedulerData * mpSchedulerData
Pointer to the element in scheduler list.
Definition: task.hxx:47
TaskPriority mePriority
Task priority.
Definition: task.hxx:49
void SetStatic()
This function must be called for static tasks, so the Task destructor ignores the scheduler mutex,...
Definition: task.hxx:109
virtual void Invoke()=0
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
aCursorMoveIdle Stop()
bool mbActive
TaskPriority mePriority
Task priority.
TaskPriority
Definition: task.hxx:28
@ RESIZE
Resize runs before repaint, so we won't paint twice.
@ POST_PAINT
Everything running directly after painting.
@ DEFAULT_IDLE
Default idle priority.
@ LOWEST
Low, very idle cleanup tasks.
@ REPAINT
All repaint events should go in here.
@ HIGH_IDLE
Important idle events to be run before processing drawing events.
@ HIGHEST
These events should run very fast!