diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-24 11:49:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-24 14:20:24 +0200 |
commit | 848058625c7fad21e2469c95c2a2078678925a5a (patch) | |
tree | 8836a8cd5cb470529bc5609df545da3c138caa25 /framework/source | |
parent | dfbce2a556972f552d194d2358c170077915d776 (diff) |
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@collabora.co.uk>
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/helper/statusindicatorfactory.cxx | 25 | ||||
-rw-r--r-- | framework/source/helper/wakeupthread.cxx | 60 |
2 files changed, 13 insertions, 72 deletions
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: */ |