[Libreoffice-commits] core.git: framework/inc framework/Library_fwk.mk framework/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 24 12:21:43 UTC 2019


 framework/Library_fwk.mk                           |    1 
 framework/inc/helper/statusindicatorfactory.hxx    |    7 +-
 framework/inc/helper/wakeupthread.hxx              |   57 -------------------
 framework/source/helper/statusindicatorfactory.cxx |   25 ++++----
 framework/source/helper/wakeupthread.cxx           |   60 ---------------------
 5 files changed, 18 insertions(+), 132 deletions(-)

New commits:
commit 848058625c7fad21e2469c95c2a2078678925a5a
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri May 24 11:49:44 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 24 14:20:24 2019 +0200

    use vcl::Timer in StatusIndicatorFactory
    
    does not need a separate thread
    
    Change-Id: I47bf2b255a331f4ec3ea24ad3a5d4c3ca398557e
    Reviewed-on: https://gerrit.libreoffice.org/72901
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index 9057aaa6048a..3957a5ace0ff 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -88,7 +88,6 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
     framework/source/helper/uiconfigelementwrapperbase \
     framework/source/helper/uielementwrapperbase \
     framework/source/helper/vclstatusindicator \
-    framework/source/helper/wakeupthread \
     framework/source/interaction/quietinteraction \
     framework/source/jobs/job \
     framework/source/jobs/jobdata \
diff --git a/framework/inc/helper/statusindicatorfactory.hxx b/framework/inc/helper/statusindicatorfactory.hxx
index d343fe35395e..1ad060516313 100644
--- a/framework/inc/helper/statusindicatorfactory.hxx
+++ b/framework/inc/helper/statusindicatorfactory.hxx
@@ -25,7 +25,6 @@
 #include <vector>
 
 // include files of own module
-#include <helper/wakeupthread.hxx>
 #include <general.h>
 
 // include uno interfaces
@@ -45,7 +44,9 @@
 #include <com/sun/star/uno/XComponentContext.hpp>
 
 #include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weakref.hxx>
 #include <vcl/status.hxx>
+#include <vcl/timer.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <osl/thread.hxx>
 
@@ -165,7 +166,7 @@ class StatusIndicatorFactory : public  ::cppu::WeakImplHelper<
 
         /** Notify us if a fix time is over. We use it to implement an
             intelligent "Reschedule" ... */
-        rtl::Reference<WakeUpThread> m_pWakeUp;
+        boost::optional<Timer> m_xWakeUpTimer;
 
         /** Our WakeUpThread calls us in our interface method "XUpdatable::update().
             There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule()
@@ -182,6 +183,8 @@ class StatusIndicatorFactory : public  ::cppu::WeakImplHelper<
         /** prevent recursive calling of Application::Reschedule(). */
         static sal_Int32 m_nInReschedule;
 
+        DECL_LINK( WakeupTimerHdl, Timer*, void );
+
     // interface
 
     public:
diff --git a/framework/inc/helper/wakeupthread.hxx b/framework/inc/helper/wakeupthread.hxx
deleted file mode 100644
index 50e234f23713..000000000000
--- a/framework/inc/helper/wakeupthread.hxx
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- 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_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
-#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX
-
-#include <sal/config.h>
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <cppuhelper/weakref.hxx>
-#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
-#include <sal/types.h>
-#include <salhelper/thread.hxx>
-
-namespace com { namespace sun { namespace star { namespace util {
-    class XUpdatable;
-} } } }
-
-namespace framework{
-
-class WakeUpThread: public salhelper::Thread {
-    css::uno::WeakReference<css::util::XUpdatable> updatable_;
-    osl::Condition condition_;
-
-    osl::Mutex mutex_;
-    bool terminate_;
-
-    void execute() override;
-
-public:
-    WakeUpThread(css::uno::Reference<css::util::XUpdatable> const & updatable);
-
-    void stop();
-};
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx
index b4b17c1617e4..540cc3d4ade5 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -537,26 +537,27 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
     if (m_bDisableReschedule)
         return;
 
-    if (!m_pWakeUp.is())
+    if (!m_xWakeUpTimer)
     {
-        m_pWakeUp = new WakeUpThread(this);
-        m_pWakeUp->launch();
+        m_xWakeUpTimer = Timer();
+        m_xWakeUpTimer->SetInvokeHandler( LINK(this, StatusIndicatorFactory, WakeupTimerHdl) );
+        m_xWakeUpTimer->SetTimeout(25); // 25 msec
+        m_xWakeUpTimer->Start();
     }
 }
 
 void StatusIndicatorFactory::impl_stopWakeUpThread()
 {
-    rtl::Reference<WakeUpThread> wakeUp;
-    {
-        osl::MutexGuard g(m_mutex);
-        std::swap(wakeUp, m_pWakeUp);
-    }
-    if (wakeUp.is())
-    {
-        wakeUp->stop();
-    }
+    if (m_xWakeUpTimer)
+        m_xWakeUpTimer->Stop();
 }
 
+IMPL_LINK_NOARG(StatusIndicatorFactory, WakeupTimerHdl, Timer *, void)
+{
+    update();
+}
+
+
 } // namespace framework
 
 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
diff --git a/framework/source/helper/wakeupthread.cxx b/framework/source/helper/wakeupthread.cxx
deleted file mode 100644
index 503f6707a010..000000000000
--- a/framework/source/helper/wakeupthread.cxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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 .
- */
-
-#include <sal/config.h>
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/util/XUpdatable.hpp>
-#include <osl/mutex.hxx>
-#include <osl/time.h>
-
-#include <helper/wakeupthread.hxx>
-
-void framework::WakeUpThread::execute() {
-    for (;;) {
-        TimeValue t{0, 25000000}; // 25 msec
-        condition_.wait(&t);
-        {
-            osl::MutexGuard g(mutex_);
-            if (terminate_) {
-                break;
-            }
-        }
-        css::uno::Reference<css::util::XUpdatable> up(updatable_);
-        if (up.is()) {
-            up->update();
-        }
-    }
-}
-
-framework::WakeUpThread::WakeUpThread(
-    css::uno::Reference<css::util::XUpdatable> const & updatable):
-    Thread("WakeUpThread"), updatable_(updatable), terminate_(false)
-{}
-
-void framework::WakeUpThread::stop() {
-    {
-        osl::MutexGuard g(mutex_);
-        terminate_ = true;
-    }
-    condition_.set();
-    join();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list