CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FdTable< HandleT > Class Template Reference

#include <fd_table.h>

Inheritance diagram for FdTable< HandleT >:
Collaboration diagram for FdTable< HandleT >:

Classes

struct  FdWrapper
 

Public Member Functions

 FdTable (unsigned max_open_fds, const HandleT &invalid_handle)
 
void AssignFrom (const FdTable< HandleT > &other)
 
FdTable< HandleT > * Clone ()
 
int OpenFd (const HandleT &handle)
 
HandleT GetHandle (int fd)
 
int CloseFd (int fd)
 
unsigned GetMaxFds () const
 

Private Member Functions

bool IsValid (int fd)
 
- Private Member Functions inherited from SingleCopy
 SingleCopy ()
 

Private Attributes

HandleT invalid_handle_
 
unsigned fd_pivot_
 
std::vector< unsigned > fd_index_
 
std::vector< FdWrapperopen_fds_
 

Detailed Description

template<class HandleT>
class FdTable< HandleT >

This file is part of the CernVM File System. Maintains integers mapped to custom open file descriptors. File descriptors can be added, removed, and accessed. All operations take constant time. The maximum file descriptor number needs to be known upfront.

Note that new file descriptors do not necessarily have the smallest available number but any number between 0..max_open_fds.

This class is used by a couple of cache managers.

Definition at line 28 of file fd_table.h.

Constructor & Destructor Documentation

template<class HandleT>
FdTable< HandleT >::FdTable ( unsigned  max_open_fds,
const HandleT &  invalid_handle 
)
inline

Definition at line 30 of file fd_table.h.

Member Function Documentation

template<class HandleT>
void FdTable< HandleT >::AssignFrom ( const FdTable< HandleT > &  other)
inline

Used to restore the state.

Definition at line 48 of file fd_table.h.

Referenced by ExternalCacheManager::DoRestoreState().

Here is the caller graph for this function:

template<class HandleT>
FdTable<HandleT>* FdTable< HandleT >::Clone ( )
inline

Used to save the state.

Definition at line 62 of file fd_table.h.

template<class HandleT>
int FdTable< HandleT >::CloseFd ( int  fd)
inline

Releases fd back to the set of available numbers. Gracefully handles invalid handles (-EBADFD)

Definition at line 104 of file fd_table.h.

template<class HandleT>
HandleT FdTable< HandleT >::GetHandle ( int  fd)
inline

For invalid and unused numbers, the invalid handle is returned.

Definition at line 95 of file fd_table.h.

template<class HandleT>
unsigned FdTable< HandleT >::GetMaxFds ( ) const
inline

Definition at line 125 of file fd_table.h.

template<class HandleT>
bool FdTable< HandleT >::IsValid ( int  fd)
inlineprivate

Definition at line 139 of file fd_table.h.

Referenced by FdTable< ExternalCacheManager::ReadOnlyHandle >::CloseFd(), and FdTable< ExternalCacheManager::ReadOnlyHandle >::GetHandle().

Here is the caller graph for this function:

template<class HandleT>
int FdTable< HandleT >::OpenFd ( const HandleT &  handle)
inline

Registeres fd with a currently unused number. If the table is full, returns -ENFILE;

Definition at line 78 of file fd_table.h.

Member Data Documentation

template<class HandleT>
std::vector<unsigned> FdTable< HandleT >::fd_index_
private
template<class HandleT>
unsigned FdTable< HandleT >::fd_pivot_
private
template<class HandleT>
std::vector<FdWrapper> FdTable< HandleT >::open_fds_
private

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