LeechCraft 0.6.70-17335-ge406ffdcaf
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
39 NetworkDiskCacheGC ();
40 public:
41 NetworkDiskCacheGC (const NetworkDiskCacheGC&) = delete;
42 NetworkDiskCacheGC& operator= (const NetworkDiskCacheGC&) = delete;
43
48 static NetworkDiskCacheGC& Instance ();
49
60 QFuture<qint64> GetCurrentSize (const QString& path) const;
61
82 Util::DefaultScopeGuard RegisterDirectory (const QString& path,
83 const std::function<int ()>& sizeGetter);
84 private:
85 void UnregisterDirectory (const QString&, CacheSizeGetters_t::iterator);
86 void HandleCollect ();
87 };
88}
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:15
detail::ScopeGuard< detail::DefaultScopeGuardDeleter > DefaultScopeGuard
Definition util.h:132