#include <FileMap.h>
Public Member Functions | |
FileMap () | |
~FileMap () | |
bool | setBit (sfileno num) |
bool | testBit (sfileno num) const |
Test whether the num-th bit in the FileMap is set. More... | |
void | clearBit (sfileno num) |
sfileno | allocate (sfileno suggestion) |
int | capacity () const |
return the max number of slots in the FileMap More... | |
int | numFilesInMap () const |
return the number of used slots in the FileMap More... | |
Private Member Functions | |
void | grow () |
grow the FileMap (size is doubled each time, up to 2^24 bits) More... | |
FileMap (const FileMap &) | |
FileMap & | operator= (const FileMap &) |
Private Attributes | |
sfileno | capacity_ |
max number of files which can be tracked in the current store More... | |
unsigned int | usedSlots_ |
used slots in the map More... | |
unsigned int | nwords |
number of "long ints" making up the filemap More... | |
unsigned long * | bitmap |
Detailed Description
A bitmap used for managing UFS StoreEntry "file numbers".
Nth bit represents whether file number N is used. The map automatically grows to hold up to 2^24 bits. New bit is "off" or zero by default, representing unused fileno. TODO: consider using std::bitset instead.
Constructor & Destructor Documentation
◆ FileMap() [1/2]
FileMap::FileMap | ( | ) |
◆ ~FileMap()
FileMap::~FileMap | ( | ) |
Definition at line 135 of file filemap.cc.
◆ FileMap() [2/2]
|
private |
Member Function Documentation
◆ allocate()
locate an unused slot in the FileMap, possibly at or after position suggestion
Obtain the location of an unused slot in the FileMap, growing it if needed. The suggestion is only an advice; there is no guarantee that it will be followed.
Definition at line 104 of file filemap.cc.
References ALL_ONES, allocate(), bitmap, BITS_IN_A_LONG, capacity_, grow(), LONG_BIT_SHIFT, nwords, and testBit().
Referenced by allocate().
◆ capacity()
|
inline |
◆ clearBit()
void FileMap::clearBit | ( | sfileno | num | ) |
Clear the num-th bit in the FileMap
- Warning
- that clearBit doesn't do any bounds checking, nor it checks that the bit is set before clearing. The caller will have to ensure that both are true using testBit before clearing.
Definition at line 84 of file filemap.cc.
References bitmap, LONG_BIT_MASK, LONG_BIT_SHIFT, and usedSlots_.
◆ grow()
|
private |
Definition at line 45 of file filemap.cc.
References assert, bitmap, capacity_, debugs, LONG_BIT_SHIFT, nwords, xcalloc(), and xfree.
Referenced by allocate(), and setBit().
◆ numFilesInMap()
|
inline |
Definition at line 63 of file FileMap.h.
References usedSlots_.
◆ operator=()
◆ setBit()
bool FileMap::setBit | ( | sfileno | num | ) |
Set the num-th bit in the FileMap
- Warning
- FileMap's backing storage will be extended as needed to hold the representation, but if the bit is already set it will break the file number accounting, so the caller must ensure that setBit is only called if the bit is not already set, by using testBit on it before.
Definition at line 62 of file filemap.cc.
References bitmap, capacity_, grow(), LONG_BIT_MASK, LONG_BIT_SHIFT, and usedSlots_.
◆ testBit()
bool FileMap::testBit | ( | sfileno | num | ) | const |
Definition at line 92 of file filemap.cc.
References bitmap, capacity_, LONG_BIT_MASK, and LONG_BIT_SHIFT.
Referenced by allocate().
Member Data Documentation
◆ bitmap
|
private |
Definition at line 76 of file FileMap.h.
Referenced by FileMap(), ~FileMap(), allocate(), clearBit(), grow(), setBit(), and testBit().
◆ capacity_
|
private |
Definition at line 71 of file FileMap.h.
Referenced by FileMap(), allocate(), capacity(), grow(), setBit(), and testBit().
◆ nwords
|
private |
Definition at line 75 of file FileMap.h.
Referenced by FileMap(), allocate(), and grow().
◆ usedSlots_
|
private |
Definition at line 73 of file FileMap.h.
Referenced by clearBit(), numFilesInMap(), and setBit().
The documentation for this class was generated from the following files:
- src/FileMap.h
- src/filemap.cc