LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Garbage collection for a set of network disk caches. More...
#include "networkdiskcachegc.h"
Public Member Functions | |
NetworkDiskCacheGC (const NetworkDiskCacheGC &)=delete | |
NetworkDiskCacheGC & | operator= (const NetworkDiskCacheGC &)=delete |
QFuture< qint64 > | GetCurrentSize (const QString &path) const |
Schedules calculation of the path total size. More... | |
Util::DefaultScopeGuard | RegisterDirectory (const QString &path, const std::function< int()> &sizeGetter) |
Registers the given cache path. More... | |
Static Public Member Functions | |
static NetworkDiskCacheGC & | Instance () |
Returns a single global instance of the GC manager. More... | |
Garbage collection for a set of network disk caches.
This GC manager class aids having multiple network disk caches at the same path and running garbage collection periodically on them, but only once per each path.
Definition at line 30 of file networkdiskcachegc.h.
|
delete |
QFuture< qint64 > LC::Util::NetworkDiskCacheGC::GetCurrentSize | ( | const QString & | path | ) | const |
Schedules calculation of the path total size.
The calculation is performed asynchronously in a separate thread, and a future object is returned which can be used to be notified when the calculation finishes.
[in] | path | The path which total size should be calculated |
Definition at line 72 of file networkdiskcachegc.cpp.
|
static |
Returns a single global instance of the GC manager.
Definition at line 39 of file networkdiskcachegc.cpp.
References Items_, and TotalSize_.
|
delete |
Util::DefaultScopeGuard LC::Util::NetworkDiskCacheGC::RegisterDirectory | ( | const QString & | path, |
const std::function< int()> & | sizeGetter | ||
) |
Registers the given cache path.
Registers the given path to be collected periodically and returns a guard object that unregisters the path when it is destroyed.
The path stops being collected as soon as the last guard object returned from this method is destroyed.
This function also takes a size getter functor returning the desired cache size for the given path. If the same path is registered multiple times with size getters returning different values, the minimum one is used.
[in] | path | The path to register for garbage collection. |
[in] | sizeGetter | The functor returning the desired total size of files under the path. |
Definition at line 77 of file networkdiskcachegc.cpp.