Alexandria
2.19
Please provide a description of the project.
|
#include <LRUFileManager.h>
Public Member Functions | |
LRUFileManager (unsigned limit=500) | |
virtual | ~LRUFileManager () |
void | notifyUsed (FileId id) override |
unsigned | getLimit () const |
unsigned | getUsed () const |
unsigned | getAvailable () const |
![]() | |
FileManager () | |
Constructor. More... | |
virtual | ~FileManager () |
Destructor. More... | |
std::shared_ptr< FileHandler > | getFileHandler (const boost::filesystem::path &path) |
template<typename TFD > | |
std::pair< FileId, TFD > | open (const boost::filesystem::path &path, bool write, std::function< bool(FileId)> request_close) |
template<typename TFD > | |
void | close (FileId id, TFD &fd) |
void | closeAll () |
bool | hasHandler (const boost::filesystem::path &path) const |
![]() | |
T | enable_shared_from_this (T...args) |
T | operator= (T...args) |
T | shared_from_this (T...args) |
T | ~enable_shared_from_this (T...args) |
Protected Member Functions | |
void | notifyIntentToOpen (bool write) override |
void | notifyOpenedFile (FileId id) override |
void | notifyClosedFile (FileId id) override |
Private Attributes | |
unsigned | m_limit |
std::list< FileId > | m_sorted_ids |
Sorted from less to more recent. More... | |
std::map< FileId, std::list < FileId >::iterator > | m_current_pos |
Additional Inherited Members | |
![]() | |
using | FileId = FileMetadata * |
Opaque FileId, its concrete type should only be assumed to be copyable and hashable. More... | |
![]() | |
static std::shared_ptr < FileManager > | getDefault () |
![]() | |
using | Clock = std::chrono::steady_clock |
using | Timestamp = Clock::time_point |
![]() | |
std::mutex | m_mutex |
std::map < boost::filesystem::path, std::weak_ptr< FileHandler > > | m_handlers |
std::map< FileId, std::unique_ptr< FileMetadata > > | m_files |
Least Recently Used strategy for the FileManager
Definition at line 30 of file LRUFileManager.h.
|
explicit |
Constructor
limit | Limit on the number of open files. If 0, it will query the system to obtain the configured limit. |
Definition at line 26 of file LRUFileManager.cpp.
References m_limit.
|
virtual |
Definition at line 35 of file LRUFileManager.cpp.
References Euclid::FilePool::FileManager::closeAll().
unsigned int Euclid::FilePool::LRUFileManager::getAvailable | ( | ) | const |
Definition at line 97 of file LRUFileManager.cpp.
References m_limit, m_sorted_ids, and std::list< T >::size().
unsigned int Euclid::FilePool::LRUFileManager::getLimit | ( | ) | const |
Definition at line 89 of file LRUFileManager.cpp.
References m_limit.
unsigned int Euclid::FilePool::LRUFileManager::getUsed | ( | ) | const |
Definition at line 93 of file LRUFileManager.cpp.
References m_sorted_ids, and std::list< T >::size().
|
overrideprotectedvirtual |
Implements Euclid::FilePool::FileManager.
Definition at line 67 of file LRUFileManager.cpp.
References std::map< K, T >::erase(), std::list< T >::erase(), m_current_pos, Euclid::FilePool::FileManager::m_mutex, and m_sorted_ids.
|
overrideprotectedvirtual |
Implements Euclid::FilePool::FileManager.
Definition at line 39 of file LRUFileManager.cpp.
References std::unique_lock::lock(), Euclid::FilePool::FileManager::m_files, m_limit, Euclid::FilePool::FileManager::m_mutex, m_sorted_ids, std::map< K, T >::size(), and std::unique_lock::unlock().
|
overrideprotectedvirtual |
Implements Euclid::FilePool::FileManager.
Definition at line 60 of file LRUFileManager.cpp.
References std::list< T >::emplace_back(), std::list< T >::end(), m_current_pos, Euclid::FilePool::FileManager::m_mutex, and m_sorted_ids.
|
overridevirtual |
Notify that the given file has been/is going to be used. This will update the book-keeping data used to decide what to close when.
Reimplemented from Euclid::FilePool::FileManager.
Definition at line 74 of file LRUFileManager.cpp.
References std::list< T >::emplace_back(), std::list< T >::end(), std::list< T >::erase(), m_current_pos, Euclid::FilePool::FileManager::m_mutex, m_sorted_ids, std::move(), and std::chrono::steady_clock::now().
|
private |
Definition at line 55 of file LRUFileManager.h.
Referenced by notifyClosedFile(), notifyOpenedFile(), and notifyUsed().
|
private |
Definition at line 52 of file LRUFileManager.h.
Referenced by getAvailable(), getLimit(), LRUFileManager(), and notifyIntentToOpen().
Sorted from less to more recent.
Definition at line 54 of file LRUFileManager.h.
Referenced by getAvailable(), getUsed(), notifyClosedFile(), notifyIntentToOpen(), notifyOpenedFile(), and notifyUsed().