LibreOffice Module sw (master) 1
finalthreadmanager.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SW_SOURCE_CORE_INC_FINALTHREADMANAGER_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_FINALTHREADMANAGER_HXX
22
23#include <sal/config.h>
25#include <com/sun/star/lang/XServiceInfo.hpp>
26#include <com/sun/star/util/XJobManager.hpp>
27#include <com/sun/star/frame/XTerminateListener2.hpp>
28#include <o3tl/deleter.hxx>
29#include <osl/mutex.hxx>
30#include <list>
31#include <memory>
32
33namespace com::sun::star::uno { class XComponentContext; }
34
38
39class FinalThreadManager final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,
40 css::util::XJobManager,
41 css::frame::XTerminateListener2 >
42{
43public:
44 explicit FinalThreadManager(css::uno::Reference< css::uno::XComponentContext > context);
45
46 // css::lang::XServiceInfo:
47 virtual OUString SAL_CALL getImplementationName() override;
48 virtual sal_Bool SAL_CALL supportsService(const OUString & ServiceName) override;
49 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
50
51 // css::util::XJobManager:
52 virtual void SAL_CALL registerJob(const css::uno::Reference< css::util::XCancellable > & Job) override;
53 virtual void SAL_CALL releaseJob(const css::uno::Reference< css::util::XCancellable > & Job) override;
54 virtual void SAL_CALL cancelAllJobs() override;
55
56 // css::frame::XTerminateListener2
57 virtual void SAL_CALL cancelTermination( const css::lang::EventObject& Event ) override;
58
59 // css::frame::XTerminateListener (inherited via css::frame::XTerminateListener2)
60 virtual void SAL_CALL queryTermination( const css::lang::EventObject& Event ) override;
61 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& Event ) override;
62
63 // ::com::sun:star::lang::XEventListener (inherited via css::frame::XTerminateListener)
64 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
65
66private:
68 void operator =(FinalThreadManager const &) = delete;
69
70 virtual ~FinalThreadManager() override;
71
73
74 css::uno::Reference< css::uno::XComponentContext > m_xContext;
75
76 osl::Mutex maMutex;
77
78 std::list< css::uno::Reference< css::util::XCancellable > > maThreads;
79 std::unique_ptr<CancelJobsThread> mpCancelJobsThread;
81 std::unique_ptr<SwPauseThreadStarting, o3tl::default_delete<SwPauseThreadStarting>> mpPauseThreadStarting;
82
84};
85#endif
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
thread to cancel a give list of cancellable jobs
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &Event) override
std::unique_ptr< SwPauseThreadStarting, o3tl::default_delete< SwPauseThreadStarting > > mpPauseThreadStarting
virtual OUString SAL_CALL getImplementationName() override
virtual ~FinalThreadManager() override
virtual void SAL_CALL releaseJob(const css::uno::Reference< css::util::XCancellable > &Job) override
TerminateOfficeThread * mpTerminateOfficeThread
std::list< css::uno::Reference< css::util::XCancellable > > maThreads
std::unique_ptr< CancelJobsThread > mpCancelJobsThread
virtual void SAL_CALL registerJob(const css::uno::Reference< css::util::XCancellable > &Job) override
virtual void SAL_CALL cancelAllJobs() override
FinalThreadManager(FinalThreadManager const &)=delete
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL queryTermination(const css::lang::EventObject &Event) override
void operator=(FinalThreadManager const &)=delete
FinalThreadManager(css::uno::Reference< css::uno::XComponentContext > context)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL cancelTermination(const css::lang::EventObject &Event) override
Helper class to pause starting of threads during existence of an instance of this class.
thread to terminate office, when all jobs are cancelled.
unsigned char sal_Bool