#include <OpenFdCache.h>
Inheritance diagram for oasys::OpenFdCache< _Key, _CloseFcn >:
Definition at line 41 of file OpenFdCache.h.
Public Types | |
typedef LRUList< FdListEnt > | FdList |
typedef std::map< _Key, typename FdList::iterator > | FdMap |
Public Member Functions | |
OpenFdCache (const char *logpath, size_t max) | |
int | get_and_pin (const _Key &key) |
void | unpin (const _Key &key) |
int | put_and_pin (const _Key &key, int fd) |
void | close (const _Key &key) |
void | close_all () |
Private Member Functions | |
int | evict () |
Private Attributes | |
SpinLock | lock_ |
FdList | open_fds_ |
FdMap | open_fds_map_ |
size_t | max_ |
Classes | |
struct | FdListEnt |
class | ScopedUnpin |
typedef LRUList<FdListEnt> oasys::OpenFdCache< _Key, _CloseFcn >::FdList |
Definition at line 58 of file OpenFdCache.h.
typedef std::map<_Key, typename FdList::iterator> oasys::OpenFdCache< _Key, _CloseFcn >::FdMap |
Definition at line 59 of file OpenFdCache.h.
oasys::OpenFdCache< _Key, _CloseFcn >::OpenFdCache | ( | const char * | logpath, | |
size_t | max | |||
) | [inline] |
Definition at line 61 of file OpenFdCache.h.
int oasys::OpenFdCache< _Key, _CloseFcn >::get_and_pin | ( | const _Key & | key | ) | [inline] |
Definition at line 71 of file OpenFdCache.h.
References ASSERT, ExamineDump::l, oasys::OpenFdCache< _Key, _CloseFcn >::lock_, log_debug, oasys::LRUList< _Type >::move_to_back(), oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
Referenced by oasys::FileSystemTable::get_common(), and oasys::FileSystemTable::put().
void oasys::OpenFdCache< _Key, _CloseFcn >::unpin | ( | const _Key & | key | ) | [inline] |
Unpin the fd referenced by _Key.
Definition at line 97 of file OpenFdCache.h.
References ASSERT, ExamineDump::l, oasys::OpenFdCache< _Key, _CloseFcn >::lock_, log_debug, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
Referenced by oasys::FileSystemTable::get_common(), oasys::FileSystemTable::put(), and oasys::OpenFdCache< _Key, _CloseFcn >::ScopedUnpin::~ScopedUnpin().
int oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin | ( | const _Key & | key, | |
int | fd | |||
) | [inline] |
Put an fd in the file cache which may evict unpinned fds. Also pin the fd that was just put into the cache.
N.B. There could be race when you are putting a newly opened file (and someone else is trying to do the same) into the cache. You need to check the return from put_and_pin as to whether you will need to close the file or not.
Definition at line 141 of file OpenFdCache.h.
References ASSERT, oasys::OpenFdCache< _Key, _CloseFcn >::evict(), ExamineDump::l, oasys::OpenFdCache< _Key, _CloseFcn >::lock_, log_debug, oasys::OpenFdCache< _Key, _CloseFcn >::max_, oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
Referenced by oasys::FileSystemTable::get_common(), and oasys::FileSystemTable::put().
void oasys::OpenFdCache< _Key, _CloseFcn >::close | ( | const _Key & | key | ) | [inline] |
Close a file fd and remove it from the cache.
Definition at line 183 of file OpenFdCache.h.
References ExamineDump::l, oasys::OpenFdCache< _Key, _CloseFcn >::lock_, log_debug, oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
Referenced by oasys::FileSystemTable::del().
void oasys::OpenFdCache< _Key, _CloseFcn >::close_all | ( | ) | [inline] |
Close and release all of the cached fds.
Definition at line 204 of file OpenFdCache.h.
References ExamineDump::l, oasys::OpenFdCache< _Key, _CloseFcn >::lock_, log_debug, log_warn, oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
int oasys::OpenFdCache< _Key, _CloseFcn >::evict | ( | ) | [inline, private] |
Search from the beginning of the list and throw out a single, unpinned fd.
Definition at line 239 of file OpenFdCache.h.
References ASSERT, log_debug, log_warn, oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_, and oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_.
Referenced by oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin().
SpinLock oasys::OpenFdCache< _Key, _CloseFcn >::lock_ [private] |
Definition at line 225 of file OpenFdCache.h.
Referenced by oasys::OpenFdCache< _Key, _CloseFcn >::close(), oasys::OpenFdCache< _Key, _CloseFcn >::close_all(), oasys::OpenFdCache< _Key, _CloseFcn >::get_and_pin(), oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin(), and oasys::OpenFdCache< _Key, _CloseFcn >::unpin().
FdList oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_ [private] |
Definition at line 227 of file OpenFdCache.h.
Referenced by oasys::OpenFdCache< _Key, _CloseFcn >::close(), oasys::OpenFdCache< _Key, _CloseFcn >::close_all(), oasys::OpenFdCache< _Key, _CloseFcn >::evict(), oasys::OpenFdCache< _Key, _CloseFcn >::get_and_pin(), and oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin().
FdMap oasys::OpenFdCache< _Key, _CloseFcn >::open_fds_map_ [private] |
Definition at line 228 of file OpenFdCache.h.
Referenced by oasys::OpenFdCache< _Key, _CloseFcn >::close(), oasys::OpenFdCache< _Key, _CloseFcn >::close_all(), oasys::OpenFdCache< _Key, _CloseFcn >::evict(), oasys::OpenFdCache< _Key, _CloseFcn >::get_and_pin(), oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin(), and oasys::OpenFdCache< _Key, _CloseFcn >::unpin().
size_t oasys::OpenFdCache< _Key, _CloseFcn >::max_ [private] |
Definition at line 230 of file OpenFdCache.h.
Referenced by oasys::OpenFdCache< _Key, _CloseFcn >::put_and_pin().