input/cache/Manager: add method Flush()
This commit is contained in:
16
src/input/cache/Manager.cxx
vendored
16
src/input/cache/Manager.cxx
vendored
@@ -58,6 +58,22 @@ InputCacheManager::~InputCacheManager() noexcept
|
|||||||
items_by_time.clear_and_dispose(DeleteDisposer());
|
items_by_time.clear_and_dispose(DeleteDisposer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
InputCacheManager::Flush() noexcept
|
||||||
|
{
|
||||||
|
items_by_time.remove_and_dispose_if([](const InputCacheItem &item){
|
||||||
|
return !item.IsInUse();
|
||||||
|
}, [this](InputCacheItem *item){
|
||||||
|
// TODO: eliminate code duplication, see method Remove()
|
||||||
|
assert(total_size >= item->size());
|
||||||
|
total_size -= item->size();
|
||||||
|
items_by_uri.erase(items_by_uri.iterator_to(*item));
|
||||||
|
delete item;
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: invalidate busy items and flush them later
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InputCacheManager::IsEligible(const InputStream &input) noexcept
|
InputCacheManager::IsEligible(const InputStream &input) noexcept
|
||||||
{
|
{
|
||||||
|
2
src/input/cache/Manager.hxx
vendored
2
src/input/cache/Manager.hxx
vendored
@@ -72,6 +72,8 @@ public:
|
|||||||
explicit InputCacheManager(const InputCacheConfig &config) noexcept;
|
explicit InputCacheManager(const InputCacheConfig &config) noexcept;
|
||||||
~InputCacheManager() noexcept;
|
~InputCacheManager() noexcept;
|
||||||
|
|
||||||
|
void Flush() noexcept;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool Contains(const char *uri) noexcept;
|
bool Contains(const char *uri) noexcept;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user