From 848058625c7fad21e2469c95c2a2078678925a5a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 24 May 2019 11:49:44 +0200 Subject: 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 --- framework/source/helper/statusindicatorfactory.cxx | 25 ++++----- framework/source/helper/wakeupthread.cxx | 60 ---------------------- 2 files changed, 13 insertions(+), 72 deletions(-) delete mode 100644 framework/source/helper/wakeupthread.cxx (limited to 'framework/source') 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 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 - -#include -#include -#include -#include - -#include - -void framework::WakeUpThread::execute() { - for (;;) { - TimeValue t{0, 25000000}; // 25 msec - condition_.wait(&t); - { - osl::MutexGuard g(mutex_); - if (terminate_) { - break; - } - } - css::uno::Reference up(updatable_); - if (up.is()) { - up->update(); - } - } -} - -framework::WakeUpThread::WakeUpThread( - css::uno::Reference 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: */ -- cgit