|
Squid Web Cache master
|
#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. | |
| void | clearBit (sfileno num) |
| sfileno | allocate (sfileno suggestion) |
| int | capacity () const |
| return the max number of slots in the FileMap | |
| int | numFilesInMap () const |
| return the number of used slots in the FileMap | |
Private Member Functions | |
| void | grow () |
| grow the FileMap (size is doubled each time, up to 2^24 bits) | |
| FileMap (const FileMap &) | |
| FileMap & | operator= (const FileMap &) |
Private Attributes | |
| sfileno | capacity_ |
| max number of files which can be tracked in the current store | |
| unsigned int | usedSlots_ |
| used slots in the map | |
| unsigned int | nwords |
| number of "long ints" making up the filemap | |
| unsigned long * | bitmap |
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.
| FileMap::FileMap | ( | ) |
| FileMap::~FileMap | ( | ) |
Definition at line 135 of file filemap.cc.
|
private |
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().
|
inline |
| void FileMap::clearBit | ( | sfileno | num | ) |
Clear the num-th bit in the FileMap
Definition at line 84 of file filemap.cc.
References bitmap, LONG_BIT_MASK, LONG_BIT_SHIFT, and usedSlots_.
|
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().
|
inline |
Definition at line 63 of file FileMap.h.
References usedSlots_.
| bool FileMap::setBit | ( | sfileno | num | ) |
Set the num-th bit in the FileMap
Definition at line 62 of file filemap.cc.
References bitmap, capacity_, grow(), LONG_BIT_MASK, LONG_BIT_SHIFT, and usedSlots_.
| 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().
|
private |
Definition at line 76 of file FileMap.h.
Referenced by FileMap(), ~FileMap(), allocate(), clearBit(), grow(), setBit(), and testBit().
|
private |
Definition at line 71 of file FileMap.h.
Referenced by FileMap(), allocate(), capacity(), grow(), setBit(), and testBit().
|
private |
Definition at line 75 of file FileMap.h.
Referenced by FileMap(), allocate(), and grow().
|
private |
Definition at line 73 of file FileMap.h.
Referenced by clearBit(), numFilesInMap(), and setBit().