summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTobias Madl <tobias.madl.dev@gmail.com>2015-02-26 07:33:59 +0000
committerTobias Madl <tobias.madl.dev@gmail.com>2015-03-06 12:27:10 +0000
commitf33d6800fbdc42aa75477e31be0bba5a4a5a52c1 (patch)
tree031608831e7cc2b3ceb1decc45eab74fb1f06041 /include
parent8f9b0c869222e57f738bc25d51cc6364e3c6a65a (diff)
Idle Timer: Invented Base Class
Change-Id: I03db46afcc0cb5e5d7a134b1bdd327abb542e63c
Diffstat (limited to 'include')
-rw-r--r--include/vcl/idle.hxx49
-rw-r--r--include/vcl/scheduler.hxx92
-rw-r--r--include/vcl/timer.hxx43
3 files changed, 110 insertions, 74 deletions
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index 3a63e6ef286a..9cb734546fb0 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -21,62 +21,23 @@
#define INCLUDED_VCL_IDLE_HXX
#include <tools/link.hxx>
-#include <tools/solar.h>
-#include <vcl/dllapi.h>
+#include <vcl/scheduler.hxx>
-struct ImplIdleData;
-struct ImplSVData;
-
-enum class IdlePriority {
- HIGHEST = 0,
- HIGH = 1,
- REPAINT = 2,
- RESIZE = 3,
- MEDIUM = 3,
- LOW = 4,
- LOWER = 5,
- LOWEST = 6
-};
-
-class VCL_DLLPUBLIC Idle
+class VCL_DLLPUBLIC Idle : public Scheduler
{
protected:
- ImplIdleData* mpIdleData; // Pointer to element in idle list
- sal_Int32 miPriority; // Idle priority ( maybe divergent to default)
- IdlePriority meDefaultPriority; // Default idle priority
- bool mbActive; // Currently in the scheduler
Link maIdleHdl; // Callback Link
- friend struct ImplIdleData;
-
public:
Idle();
Idle( const Idle& rIdle );
- virtual ~Idle();
-
- void SetPriority( IdlePriority ePriority );
- void SetSchedulingPriority( sal_Int32 iPriority );
- sal_Int32 GetPriority() const { return miPriority; }
- IdlePriority GetDefaultPriority() const { return meDefaultPriority; }
/// Make it possible to associate a callback with this idle handler
- /// of course, you can also sub-class and override 'DoIdle'
+ /// of course, you can also sub-class and override 'Invoke'
void SetIdleHdl( const Link& rLink ) { maIdleHdl = rLink; }
const Link& GetIdleHdl() const { return maIdleHdl; }
-
- // Call idle handler
- virtual void DoIdle();
-
- void Start();
- void Stop();
-
- bool IsActive() const { return mbActive; }
-
- Idle& operator=( const Idle& rIdle );
- static void ImplDeInitIdle();
-
- /// Process all pending idle tasks ahead of time in priority order.
- static void ProcessAllIdleHandlers();
+ virtual void Invoke() SAL_OVERRIDE;
+ Idle& operator=( const Idle& rIdle );
};
#endif // INCLUDED_VCL_IDLE_HXX
diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx
new file mode 100644
index 000000000000..a18aa71e815a
--- /dev/null
+++ b/include/vcl/scheduler.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_SCHEDULER_HXX
+#define INCLUDED_VCL_SCHEDULER_HXX
+
+#include <vcl/dllapi.h>
+
+struct ImplSVData;
+class Scheduler;
+struct ImplSchedulerData
+{
+ ImplSchedulerData* mpNext; // Pointer to the next element in list
+ Scheduler* mpScheduler; // Pointer to VCL Idle instance
+ bool mbDelete; // Destroy this idle?
+ bool mbInScheduler; // Idle handler currently processed?
+ sal_uLong mnUpdateTime; // Last Update Time
+ sal_uLong mnUpdateStack; // Update Stack on stack
+
+ void Invoke();
+
+ static ImplSchedulerData *GetMostImportantTask( bool bTimer );
+};
+
+enum class SchedulerPriority {
+ HIGHEST = 0,
+ HIGH = 1,
+ REPAINT = 2,
+ RESIZE = 3,
+ MEDIUM = 3,
+ LOW = 4,
+ LOWER = 5,
+ LOWEST = 6
+};
+
+class VCL_DLLPUBLIC Scheduler
+{
+protected:
+ ImplSchedulerData* mpSchedulerData; // Pointer to element in idle list
+ sal_Int32 miPriority; // Idle priority ( maybe divergent to default)
+ SchedulerPriority meDefaultPriority; // Default idle priority
+ bool mbActive; // Currently in the scheduler
+
+ friend struct ImplSchedulerData;
+ virtual void SetDeletionFlags();
+ virtual bool ReadyForSchedule( bool bTimer ) { return !bTimer; }
+
+public:
+ Scheduler();
+ Scheduler( const Scheduler& rScheduler );
+ virtual ~Scheduler();
+
+ void SetPriority( SchedulerPriority ePriority );
+ void SetSchedulingPriority( sal_Int32 iPriority );
+ sal_Int32 GetPriority() const { return miPriority; }
+ SchedulerPriority GetDefaultPriority() const { return meDefaultPriority; }
+
+ // Call idle handler
+ virtual void Invoke() = 0;
+
+ virtual void Start();
+ virtual void Stop();
+
+ bool IsActive() const { return mbActive; }
+
+ Scheduler& operator=( const Scheduler& Scheduler );
+ static void ImplDeInitScheduler();
+
+ /// Process all pending idle tasks ahead of time in priority order.
+ static void CallbackTaskScheduling();
+ static void ProcessTaskScheduling( bool bTimer );
+};
+
+#endif // INCLUDED_VCL_SCHEDULER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index 2d0f31076db0..01fd36c82a16 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -21,50 +21,32 @@
#define INCLUDED_VCL_TIMER_HXX
#include <tools/link.hxx>
-#include <tools/solar.h>
-#include <vcl/dllapi.h>
+#include <vcl/scheduler.hxx>
-struct ImplTimerData;
-struct ImplSVData;
-
-/// Base-class for timers - usually a simple, one-shot timeout
-class VCL_DLLPUBLIC Timer
+class VCL_DLLPUBLIC Timer : public Scheduler
{
protected:
- ImplTimerData* mpTimerData;
+ Link maTimeoutHdl; // Callback Link
sal_uLong mnTimeout;
- bool mbActive;
bool mbAuto;
- Link maTimeoutHdl;
- friend struct ImplTimerData;
+ void SetDeletionFlags() SAL_OVERRIDE;
+ bool ReadyForSchedule( bool bTimer ) SAL_OVERRIDE;
public:
- Timer();
- Timer( const Timer& rTimer );
- virtual ~Timer();
-
- virtual void Timeout();
+ Timer();
+ Timer( const Timer& rTimer );
- void Start();
- void Stop();
-
- /// set the timeout in milliseconds
+ /// Make it possible to associate a callback with this timer handler
+ /// of course, you can also sub-class and override 'Invoke'
void SetTimeout( sal_uLong nTimeoutMs );
sal_uLong GetTimeout() const { return mnTimeout; }
- bool IsActive() const { return mbActive; }
-
- /// Make it possible to associate a callback with this timeout
void SetTimeoutHdl( const Link& rLink ) { maTimeoutHdl = rLink; }
const Link& GetTimeoutHdl() const { return maTimeoutHdl; }
-
+ virtual void Invoke() SAL_OVERRIDE;
+ virtual void Timeout() { Invoke(); }
Timer& operator=( const Timer& rTimer );
-
- /// @internal
- static void ImplDeInitTimer();
- static void ImplTimerCallbackProc();
- static bool TimerReady();
- static bool CheckExpiredTimer(const bool bDoInvoke);
+ void Start() SAL_OVERRIDE;
};
/// An auto-timer is a multi-shot timer re-emitting itself at
@@ -77,6 +59,7 @@ public:
AutoTimer& operator=( const AutoTimer& rTimer );
};
+
#endif // INCLUDED_VCL_TIMER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */