LibreOffice Module sc (master) 1
sharedstringpoolpurge.cxx
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 */
10
12
13#include <algorithm>
14
15#include <vcl/svapp.hxx>
16
17namespace sc
18{
20 : mTimer("SharedStringPoolPurge")
21{
22 mTimer.SetPriority(TaskPriority::LOWEST);
23 mTimer.SetTimeout(10000); // 10 sec
25}
26
28
29void SharedStringPoolPurge::delayedPurge(const std::shared_ptr<svl::SharedStringPool>& pool)
30{
31 if (std::find(mPoolsToPurge.begin(), mPoolsToPurge.end(), pool) == mPoolsToPurge.end())
32 {
33 mPoolsToPurge.push_back(pool);
34 SolarMutexGuard guard;
35 mTimer.Start();
36 }
37}
38
40{
41 for (std::shared_ptr<svl::SharedStringPool>& pool : mPoolsToPurge)
42 {
43 if (pool.use_count() > 1)
44 pool->purge();
45 }
46 mPoolsToPurge.clear();
47}
48
50{
51 SolarMutexGuard guard;
52 mTimer.Stop();
53 cleanup();
54}
55
56} // namespace
57
58/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetPriority(TaskPriority ePriority)
void SetTimeout(sal_uInt64 nTimeoutMs)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void Start(bool bStartTimer=true) override
void delayedPurge(const std::shared_ptr< svl::SharedStringPool > &pool)
std::vector< std::shared_ptr< svl::SharedStringPool > > mPoolsToPurge
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
IMPL_LINK_NOARG(SharedStringPoolPurge, timerHandler, Timer *, void)