LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
networkdiskcachegc.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <functional>
12#include <list>
13#include <QObject>
14#include <QMap>
15#include <util/sll/util.h>
16
17template<typename T>
18class QFuture;
19
20namespace LC::Util
21{
30 class NetworkDiskCacheGC : public QObject
31 {
32 using CacheSizeGetters_t = std::list<std::function<int ()>>;
34
35 QMap<QString, qint64> LastSizes_;
36
37 bool IsCollecting_ = false;
38
40 public:
43
49
61
83 const std::function<int ()>& sizeGetter);
84 private:
85 void UnregisterDirectory (const QString&, CacheSizeGetters_t::iterator);
86 void HandleCollect ();
87 };
88}
Garbage collection for a set of network disk caches.
Util::DefaultScopeGuard RegisterDirectory(const QString &path, const std::function< int()> &sizeGetter)
Registers the given cache path.
static NetworkDiskCacheGC & Instance()
Returns a single global instance of the GC manager.
NetworkDiskCacheGC(const NetworkDiskCacheGC &)=delete
NetworkDiskCacheGC & operator=(const NetworkDiskCacheGC &)=delete
QFuture< qint64 > GetCurrentSize(const QString &path) const
Schedules calculation of the path total size.
Definition anutil.h:17
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118