diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-02-02 17:21:23 +0100 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-07-13 12:10:20 +0200 |
commit | b9ae1505e36157775b1002fdbd178d1c90cd91a9 (patch) | |
tree | e236fce90f7cf635321f827ad9c51c0a186d6395 | |
parent | d72aad218c9737fb19d1a835b03c13b7107a96c0 (diff) |
Move scheduler task into its own header
Change-Id: I54534787b8cfa4c47dc09dde9c38a7893df9d367
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 1 | ||||
-rw-r--r-- | include/vcl/scheduler.hxx | 68 | ||||
-rw-r--r-- | include/vcl/task.hxx | 92 | ||||
-rw-r--r-- | include/vcl/timer.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/dataproviders_test.cxx | 1 | ||||
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 1 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 1 | ||||
-rw-r--r-- | vcl/inc/saltimer.hxx | 25 | ||||
-rw-r--r-- | vcl/inc/schedulerimpl.hxx | 43 | ||||
-rw-r--r-- | vcl/qa/cppunit/lifecycle.cxx | 1 | ||||
-rw-r--r-- | vcl/source/app/idle.cxx | 1 | ||||
-rw-r--r-- | vcl/source/app/scheduler.cxx | 18 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 3 | ||||
-rw-r--r-- | vcl/source/app/timer.cxx | 2 | ||||
-rw-r--r-- | vcl/source/uitest/uno/uiobject_uno.cxx | 1 |
17 files changed, 164 insertions, 98 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 0152bfa4aa05..58aea8beb431 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -39,6 +39,7 @@ #include <cairo.h> #include <ostream> #include <config_features.h> +#include <vcl/scheduler.hxx> #include <lib/init.hxx> diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx index 86c6c5bead01..aeb8e6cf7dbc 100644 --- a/include/vcl/scheduler.hxx +++ b/include/vcl/scheduler.hxx @@ -23,13 +23,13 @@ #include <vcl/dllapi.h> class Task; +struct TaskImpl; -class VCL_DLLPUBLIC Scheduler +class VCL_DLLPUBLIC Scheduler final { friend class Task; Scheduler() = delete; -protected: static void ImplStartTimer ( sal_uInt64 nMS, bool bForce = false ); public: @@ -58,70 +58,6 @@ public: static bool GetDeterministicMode(); }; - -struct ImplSchedulerData; - -enum class TaskPriority -{ - HIGHEST = 0, - HIGH = 1, - RESIZE = 2, - REPAINT = 3, - MEDIUM = 3, - POST_PAINT = 4, - DEFAULT_IDLE = 5, - LOW = 6, - LOWER = 7, - LOWEST = 8 -}; - -class VCL_DLLPUBLIC Task -{ - friend class Scheduler; - friend struct ImplSchedulerData; - - ImplSchedulerData *mpSchedulerData; /// Pointer to the element in scheduler list - const sal_Char *mpDebugName; /// Useful for debugging - TaskPriority mePriority; /// Task priority - bool mbActive; /// Currently in the scheduler - -protected: - static void StartTimer( sal_uInt64 nMS ); - - const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; } - - virtual void SetDeletionFlags(); - /// Is this item ready to be dispatched at nTimeNow - virtual bool ReadyForSchedule( bool bIdle, sal_uInt64 nTimeNow ) const = 0; - /// Schedule only when other timers and events are processed - virtual bool IsIdle() const = 0; - /** - * Adjust nMinPeriod downwards if we want to be notified before - * then, nTimeNow is the current time. - */ - virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const = 0; - -public: - Task( const sal_Char *pDebugName ); - Task( const Task& rTask ); - virtual ~Task() COVERITY_NOEXCEPT_FALSE; - Task& operator=( const Task& rTask ); - - void SetPriority(TaskPriority ePriority) { mePriority = ePriority; } - TaskPriority GetPriority() const { return mePriority; } - - void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; } - const char *GetDebugName() const { return mpDebugName; } - - // Call handler - virtual void Invoke() = 0; - - virtual void Start(); - void Stop(); - - bool IsActive() const { return mbActive; } -}; - #endif // INCLUDED_VCL_SCHEDULER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx new file mode 100644 index 000000000000..a9fd60c87404 --- /dev/null +++ b/include/vcl/task.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_TASK_HXX +#define INCLUDED_VCL_TASK_HXX + +#include <vcl/dllapi.h> +#include <memory> + +class Scheduler; +struct ImplSchedulerData; + +enum class TaskPriority +{ + HIGHEST = 0, + HIGH = 1, + RESIZE = 2, + REPAINT = 3, + MEDIUM = 3, + POST_PAINT = 4, + DEFAULT_IDLE = 5, + LOW = 6, + LOWER = 7, + LOWEST = 8 +}; + +class VCL_DLLPUBLIC Task +{ + friend class Scheduler; + friend struct ImplSchedulerData; + + ImplSchedulerData *mpSchedulerData; ///< Pointer to the element in scheduler list + const sal_Char *mpDebugName; ///< Useful for debugging + TaskPriority mePriority; ///< Task priority + bool mbActive; ///< Currently in the scheduler + +protected: + static void StartTimer( sal_uInt64 nMS ); + + const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; } + + virtual void SetDeletionFlags(); + /// Is this item ready to be dispatched at nTimeNow + virtual bool ReadyForSchedule( bool bIdle, sal_uInt64 nTimeNow ) const = 0; + /// Schedule only when other timers and events are processed + virtual bool IsIdle() const = 0; + /** + * Adjust nMinPeriod downwards if we want to be notified before + * then, nTimeNow is the current time. + */ + virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTimeNow ) const = 0; + +public: + Task( const sal_Char *pDebugName ); + Task( const Task& rTask ); + virtual ~Task() COVERITY_NOEXCEPT_FALSE; + Task& operator=( const Task& rTask ); + + void SetPriority(TaskPriority ePriority) { mePriority = ePriority; } + TaskPriority GetPriority() const { return mePriority; } + + void SetDebugName( const sal_Char *pDebugName ) { mpDebugName = pDebugName; } + const char *GetDebugName() const { return mpDebugName; } + + // Call handler + virtual void Invoke() = 0; + + virtual void Start(); + void Stop(); + + bool IsActive() const { return mbActive; } +}; + +#endif // INCLUDED_VCL_TASK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index c7bf7253a2d3..c7dccd7fc421 100644 --- a/include/vcl/timer.hxx +++ b/include/vcl/timer.hxx @@ -21,7 +21,7 @@ #define INCLUDED_VCL_TIMER_HXX #include <tools/link.hxx> -#include <vcl/scheduler.hxx> +#include <vcl/task.hxx> class VCL_DLLPUBLIC Timer : public Task { diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx index 4dd967376f58..df5b248d4021 100644 --- a/sc/qa/unit/dataproviders_test.cxx +++ b/sc/qa/unit/dataproviders_test.cxx @@ -13,6 +13,7 @@ #include <stringutil.hxx> #include "address.hxx" #include "dataprovider.hxx" +#include <vcl/scheduler.hxx> #include <memory> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 521735ebd4fc..f966627ca1c7 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -31,6 +31,7 @@ #include <comphelper/propertyvalue.hxx> #include <sfx2/lokhelper.hxx> #include <svx/svdpage.hxx> +#include <vcl/scheduler.hxx> #include <chrono> #include <cstddef> diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 715b444e5262..b5c2e0107639 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -46,6 +46,7 @@ #include <svx/svxids.hrc> #include <DrawViewShell.hxx> #include <pres.hxx> +#include <vcl/scheduler.hxx> #include <chrono> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 1d5926c33a88..b33e8ea42206 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -33,6 +33,7 @@ #include <sfx2/lokhelper.hxx> #include <redline.hxx> #include <IDocumentRedlineAccess.hxx> +#include <vcl/scheduler.hxx> static const char* const DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d3b59c560463..32df03c73071 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -104,6 +104,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/configurationhelper.hxx> #include <editeng/unolingu.hxx> +#include <vcl/scheduler.hxx> #include <config_features.h> #include <sfx2/watermarkitem.hxx> diff --git a/vcl/inc/saltimer.hxx b/vcl/inc/saltimer.hxx index fcf450d28a7b..e9f28169bf35 100644 --- a/vcl/inc/saltimer.hxx +++ b/vcl/inc/saltimer.hxx @@ -55,31 +55,6 @@ public: } }; -class Task; - -// Internal scheduler record holding intrusive linked list pieces -struct ImplSchedulerData -{ - ImplSchedulerData *mpNext; // Pointer to the next element in list - Task *mpTask; // Pointer to VCL Task instance - bool mbDelete; // Destroy this task? - bool mbInScheduler; // Task currently processed? - sal_uInt64 mnUpdateTime; // Last Update Time - - void Invoke(); - - const char *GetDebugName() const; -}; - -template< typename charT, typename traits > -inline std::basic_ostream<charT, traits> & operator <<( - std::basic_ostream<charT, traits> & stream, const ImplSchedulerData& data ) -{ - stream << " i: " << data.mbInScheduler - << " d: " << data.mbDelete; - return stream; -} - #endif // INCLUDED_VCL_INC_SALTIMER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/schedulerimpl.hxx b/vcl/inc/schedulerimpl.hxx new file mode 100644 index 000000000000..af5f532df39a --- /dev/null +++ b/vcl/inc/schedulerimpl.hxx @@ -0,0 +1,43 @@ +/* -*- 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_INC_SCHEDULERIMPL_HXX +#define INCLUDED_VCL_INC_SCHEDULERIMPL_HXX + +#include <salwtype.hxx> + +class Task; + +// Internal scheduler record holding intrusive linked list pieces +struct ImplSchedulerData final +{ + ImplSchedulerData* mpNext; ///< Pointer to the next element in list + Task* mpTask; ///< Pointer to VCL Task instance + bool mbDelete; ///< Destroy this task? + bool mbInScheduler; ///< Task currently processed? + sal_uInt64 mnUpdateTime; ///< Last Update Time + + void Invoke(); + + const char *GetDebugName() const; +}; + +#endif // INCLUDED_VCL_INC_SCHEDULERIMPL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx index b3a73af757a3..6cede7ceee4d 100644 --- a/vcl/qa/cppunit/lifecycle.cxx +++ b/vcl/qa/cppunit/lifecycle.cxx @@ -20,6 +20,7 @@ #include <vcl/dialog.hxx> #include <vcl/layout.hxx> #include <vcl/svapp.hxx> +#include <vcl/scheduler.hxx> #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/XComponent.hpp> diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx index a086b5f5c8c9..8f5f8c002b08 100644 --- a/vcl/source/app/idle.cxx +++ b/vcl/source/app/idle.cxx @@ -18,6 +18,7 @@ */ #include <vcl/idle.hxx> +#include <vcl/scheduler.hxx> #include "saltimer.hxx" Idle::Idle( bool bAuto, const sal_Char *pDebugName ) diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index b1b456e51625..4278891ec16a 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -19,10 +19,13 @@ #include <svdata.hxx> #include <tools/time.hxx> +#include <vcl/scheduler.hxx> #include <vcl/idle.hxx> #include <saltimer.hxx> #include <salinst.hxx> #include <comphelper/profilezone.hxx> +#include <schedulerimpl.hxx> +#include <svdata.hxx> namespace { const sal_uInt64 MaximumTimeoutMs = 1000 * 60; // 1 minute @@ -71,8 +74,17 @@ inline std::basic_ostream<charT, traits> & operator <<( return stream << static_cast<const Timer*>( &idle ); } +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const ImplSchedulerData& data ) +{ + stream << " i: " << data.mbInScheduler + << " d: " << data.mbDelete; + return stream; } +} // end anonymous namespace + void ImplSchedulerData::Invoke() { DBG_TESTSOLARMUTEX(); @@ -306,12 +318,6 @@ sal_uInt64 Scheduler::CalculateMinimumTimeout( bool &bHasActiveIdles ) return nMinPeriod; } -const char *ImplSchedulerData::GetDebugName() const -{ - return mpTask && mpTask->GetDebugName() ? - mpTask->GetDebugName() : "unknown"; -} - void Task::StartTimer( sal_uInt64 nMS ) { Scheduler::ImplStartTimer( nMS, false ); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 0116b3b596c8..ea6e0807cc7e 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -64,6 +64,9 @@ #include "window.h" #include "accmgr.hxx" #include "svids.hrc" +#if OSL_DEBUG_LEVEL > 0 +#include "schedulerimpl.hxx" +#endif #include <com/sun/star/uno/Reference.h> #include <com/sun/star/awt/XToolkit.hpp> diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx index 56f0922963b8..924ef62d0881 100644 --- a/vcl/source/app/timer.cxx +++ b/vcl/source/app/timer.cxx @@ -19,7 +19,9 @@ #include <tools/time.hxx> #include <vcl/timer.hxx> +#include <vcl/scheduler.hxx> #include "saltimer.hxx" +#include "schedulerimpl.hxx" void Timer::SetDeletionFlags() { diff --git a/vcl/source/uitest/uno/uiobject_uno.cxx b/vcl/source/uitest/uno/uiobject_uno.cxx index 90205a5dff8e..317a06db6360 100644 --- a/vcl/source/uitest/uno/uiobject_uno.cxx +++ b/vcl/source/uitest/uno/uiobject_uno.cxx @@ -13,6 +13,7 @@ #include <o3tl/make_unique.hxx> #include <vcl/svapp.hxx> #include <vcl/idle.hxx> +#include <vcl/scheduler.hxx> #include <set> #include <chrono> |