Alexandria 2.32.0
SDC-CH common library for the Euclid 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 |
Public Member Functions inherited from Euclid::FilePool::FileManager | |
FileManager () | |
Constructor. | |
virtual | ~FileManager () |
Destructor. | |
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 |
Public Member Functions inherited from std::enable_shared_from_this< FileManager > | |
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::mutex | m_close_fd_mutex |
std::list< FileId > | m_sorted_ids |
Sorted from less to more recent. | |
std::map< FileId, std::list< FileId >::iterator > | m_current_pos |
Additional Inherited Members | |
Public Types inherited from Euclid::FilePool::FileManager | |
using | FileId = intptr_t |
Opaque FileId, its concrete type should only be assumed to be copyable and hashable. | |
Static Public Member Functions inherited from Euclid::FilePool::FileManager | |
static std::shared_ptr< FileManager > | getDefault () |
Protected Types inherited from Euclid::FilePool::FileManager | |
using | Clock = std::chrono::steady_clock |
using | Timestamp = Clock::time_point |
Protected Attributes inherited from Euclid::FilePool::FileManager | |
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 100 of file LRUFileManager.cpp.
References m_limit, and m_sorted_ids.
unsigned int Euclid::FilePool::LRUFileManager::getLimit | ( | ) | const |
Definition at line 92 of file LRUFileManager.cpp.
References m_limit.
unsigned int Euclid::FilePool::LRUFileManager::getUsed | ( | ) | const |
Definition at line 96 of file LRUFileManager.cpp.
References m_sorted_ids.
|
overrideprotectedvirtual |
Implements Euclid::FilePool::FileManager.
Definition at line 69 of file LRUFileManager.cpp.
References 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 m_close_fd_mutex, Euclid::FilePool::FileManager::m_files, m_limit, Euclid::FilePool::FileManager::m_mutex, and m_sorted_ids.
|
overrideprotectedvirtual |
Implements Euclid::FilePool::FileManager.
Definition at line 62 of file LRUFileManager.cpp.
References 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 76 of file LRUFileManager.cpp.
References m_current_pos, Euclid::FilePool::FileManager::m_mutex, m_sorted_ids, std::move(), and std::chrono::steady_clock::now().
|
private |
Definition at line 53 of file LRUFileManager.h.
Referenced by notifyIntentToOpen().
|
private |
Definition at line 56 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 55 of file LRUFileManager.h.
Referenced by getAvailable(), getUsed(), notifyClosedFile(), notifyIntentToOpen(), notifyOpenedFile(), and notifyUsed().