lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / vcl / task.hxx
blob0fc124de7a65e4e4bd2c93d2f2144abf771e9d85
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_TASK_HXX
21 #define INCLUDED_VCL_TASK_HXX
23 #include <vcl/dllapi.h>
25 struct ImplSchedulerData;
27 enum class TaskPriority
29 HIGHEST, ///< These events should run very fast!
30 DEFAULT, ///< Default priority used, e.g. the default timer priority
31 HIGH_IDLE, ///< Important idle events to be run before processing drawing events
32 RESIZE, ///< Resize runs before repaint, so we won't paint twice
33 REPAINT, ///< All repaint events should go in here
34 POST_PAINT, ///< Everything running directly after painting
35 DEFAULT_IDLE, ///< Default idle priority
36 LOWEST ///< Low, very idle cleanup tasks
39 #define PRIO_COUNT (static_cast<int>(TaskPriority::LOWEST) + 1)
41 class VCL_DLLPUBLIC Task
43 friend class Scheduler;
44 friend struct ImplSchedulerData;
46 ImplSchedulerData *mpSchedulerData; ///< Pointer to the element in scheduler list
47 const sal_Char *mpDebugName; ///< Useful for debugging
48 TaskPriority mePriority; ///< Task priority
49 bool mbActive; ///< Currently in the scheduler
50 bool mbStatic; ///< Is a static object
52 protected:
53 static void StartTimer( sal_uInt64 nMS );
55 const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; }
57 virtual void SetDeletionFlags();
59 /**
60 * How long (in MS) until the Task is ready to be dispatched?
62 * Simply return Scheduler::ImmediateTimeoutMs if you're ready, like an
63 * Idle. If you have to return Scheduler::InfiniteTimeoutMs, you probably
64 * need another mechanism to wake up the Scheduler or rely on other
65 * Tasks to be scheduled, or simply use a polling Timer.
67 * @param nTimeNow the current time
68 * @return the sleep time of the Task to become ready
70 virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nTimeNow ) const = 0;
72 public:
73 Task( const sal_Char *pDebugName );
74 Task( const Task& rTask );
75 virtual ~Task() COVERITY_NOEXCEPT_FALSE;
76 Task& operator=( const Task& rTask );
78 void SetPriority(TaskPriority ePriority);
79 TaskPriority GetPriority() const { return mePriority; }
81 void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; }
82 const char *GetDebugName() const { return mpDebugName; }
84 // Call handler
85 virtual void Invoke() = 0;
87 virtual void Start();
88 void Stop();
90 bool IsActive() const { return mbActive; }
92 /**
93 * This function must be called for static tasks, so the Task destructor
94 * ignores the SchedulerMutex, as it may not be available anymore.
95 * The cleanup is still correct, as it has already happened in
96 * DeInitScheduler call well before the static destructor calls.
98 void SetStatic() { mbStatic = true; }
99 bool IsStatic() const { return mbStatic; }
102 #endif // INCLUDED_VCL_TASK_HXX
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */