1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
11 #include <sharedstringpoolpurge.hxx>
15 #include <vcl/svapp.hxx>
19 SharedStringPoolPurge::SharedStringPoolPurge()
20 : mTimer("SharedStringPoolPurge")
22 mTimer
.SetPriority(TaskPriority::LOWEST
);
23 mTimer
.SetTimeout(10000); // 10 sec
24 mTimer
.SetInvokeHandler(LINK(this, SharedStringPoolPurge
, timerHandler
));
27 SharedStringPoolPurge::~SharedStringPoolPurge() { cleanup(); }
29 void SharedStringPoolPurge::delayedPurge(const std::shared_ptr
<svl::SharedStringPool
>& pool
)
31 if (std::find(mPoolsToPurge
.begin(), mPoolsToPurge
.end(), pool
) == mPoolsToPurge
.end())
33 mPoolsToPurge
.push_back(pool
);
34 SolarMutexGuard guard
;
39 void SharedStringPoolPurge::cleanup()
41 for (std::shared_ptr
<svl::SharedStringPool
>& pool
: mPoolsToPurge
)
43 if (pool
.use_count() > 1)
46 mPoolsToPurge
.clear();
49 IMPL_LINK_NOARG(SharedStringPoolPurge
, timerHandler
, Timer
*, void)
51 SolarMutexGuard guard
;
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */