LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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
17
template
<
typename
T>
18
class
QFuture
;
19
20
namespace
LC::Util
21
{
30
class
NetworkDiskCacheGC
:
public
QObject
31
{
32
using
CacheSizeGetters_t = std::list<std::function<int ()>>;
33
QMap<QString, CacheSizeGetters_t>
Directories_;
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
}
LC::Util::NetworkDiskCacheGC
Garbage collection for a set of network disk caches.
Definition:
networkdiskcachegc.h:30
LC::Util
Definition:
icoreproxy.h:33
LC::Util::NetworkDiskCacheGC::RegisterDirectory
Util::DefaultScopeGuard RegisterDirectory(const QString &path, const std::function< int()> &sizeGetter)
Registers the given cache path.
Definition:
networkdiskcachegc.cpp:77
util.h
LC::Util::NetworkDiskCacheGC::GetCurrentSize
QFuture< qint64 > GetCurrentSize(const QString &path) const
Schedules calculation of the path total size.
Definition:
networkdiskcachegc.cpp:72
LC::Util::detail::ScopeGuard
Definition:
util.h:61
LC::Util::NetworkDiskCacheGC::operator=
NetworkDiskCacheGC & operator=(const NetworkDiskCacheGC &)=delete
LC::Util::NetworkDiskCacheGC::Instance
static NetworkDiskCacheGC & Instance()
Returns a single global instance of the GC manager.
Definition:
networkdiskcachegc.cpp:39
QFuture
Definition:
idownload.h:17
QMap< QString, CacheSizeGetters_t >
src
util
network
networkdiskcachegc.h
Generated by
1.8.17