tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / vcl / inc / graphic / Manager.hxx
blob0a4ee3fbc84d1ff48cb7977ef1c4938f5a4717b6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #pragma once
12 #include <sal/types.h>
13 #include <rtl/strbuf.hxx>
14 #include <vcl/timer.hxx>
16 #include <memory>
17 #include <mutex>
18 #include <chrono>
19 #include <o3tl/sorted_vector.hxx>
21 namespace vcl::graphic
23 class MemoryManaged;
25 class VCL_DLLPUBLIC MemoryManager final
27 private:
28 o3tl::sorted_vector<MemoryManaged*> maObjectList;
29 sal_Int64 mnTotalSize = 0;
30 std::mutex maMutex; // instead of SolarMutex because graphics can live past vcl main
32 std::chrono::seconds mnAllowedIdleTime = std::chrono::seconds(1);
33 bool mbSwapEnabled = true;
34 bool mbReducingGraphicMemory = false;
35 sal_Int64 mnMemoryLimit = 10'000'000;
36 Timer maSwapOutTimer;
37 sal_Int32 mnTimeout = 1'000;
38 sal_Int64 mnSmallFrySize = 100'000;
40 DECL_LINK(ReduceMemoryTimerHandler, Timer*, void);
42 public:
43 MemoryManager();
44 void registerObject(MemoryManaged* pObject);
45 void unregisterObject(MemoryManaged* pObject);
46 void changeExisting(MemoryManaged* pObject, sal_Int64 nNewSize);
48 void swappedIn(MemoryManaged* pObject, sal_Int64 nNewSize);
49 void swappedOut(MemoryManaged* pObject, sal_Int64 nNewSize);
51 static MemoryManager& get();
52 o3tl::sorted_vector<MemoryManaged*> const& getManagedObjects() { return maObjectList; }
53 sal_Int64 getTotalSize() { return mnTotalSize; }
55 void reduceMemory(std::unique_lock<std::mutex>& rGuard, bool bDropAll = false);
56 void loopAndReduceMemory(std::unique_lock<std::mutex>& rGuard, bool bDropAll = false);
57 void reduceAllAndNow();
58 void dumpState(rtl::OStringBuffer& rState);
61 } // end namespace vcl::graphic
63 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */