LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::NetworkDiskCacheGC Class Reference

Garbage collection for a set of network disk caches. More...

#include "networkdiskcachegc.h"

+ Inheritance diagram for LC::Util::NetworkDiskCacheGC:
+ Collaboration diagram for LC::Util::NetworkDiskCacheGC:

Public Member Functions

 NetworkDiskCacheGC (const NetworkDiskCacheGC &)=delete
 
NetworkDiskCacheGCoperator= (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 NetworkDiskCacheGCInstance ()
 Returns a single global instance of the GC manager. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ NetworkDiskCacheGC()

LC::Util::NetworkDiskCacheGC::NetworkDiskCacheGC ( const NetworkDiskCacheGC )
delete

Member Function Documentation

◆ GetCurrentSize()

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.

Parameters
[in]pathThe path which total size should be calculated
Returns
The future object for the asynchronous path size calculation.

Definition at line 72 of file networkdiskcachegc.cpp.

◆ Instance()

NetworkDiskCacheGC & LC::Util::NetworkDiskCacheGC::Instance ( )
static

Returns a single global instance of the GC manager.

Returns
The single global instance of the GC manager.

Definition at line 39 of file networkdiskcachegc.cpp.

References Items_, and TotalSize_.

◆ operator=()

NetworkDiskCacheGC& LC::Util::NetworkDiskCacheGC::operator= ( const NetworkDiskCacheGC )
delete

◆ RegisterDirectory()

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.

Parameters
[in]pathThe path to register for garbage collection.
[in]sizeGetterThe functor returning the desired total size of files under the path.
Returns
A guard object unregistering the path when it is destroyed.

Definition at line 77 of file networkdiskcachegc.cpp.


The documentation for this class was generated from the following files: