headers/private/kernel/util/OpenHashTable.h, Hugo's version, is a bit nicer than

Tracker's OpenHashTable.h which it should eventually replace. We've renamed the
class to BOpenHashTable and changed the interface slightly so that HashTableLink
became superfluous.
Adapted all the code that used it. Since the OpenHashTables no longer clash,
this should fix the GCC4 build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31791 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-07-27 00:39:12 +00:00
parent 8e1857f795
commit 5147963dcd
59 changed files with 346 additions and 311 deletions
+5 -5
View File
@@ -108,11 +108,11 @@ public:
NotificationListener& listener) = 0; NotificationListener& listener) = 0;
virtual const char* Name() = 0; virtual const char* Name() = 0;
HashTableLink<NotificationService>& NotificationService*&
Link() { return fLink; } Link() { return fLink; }
private: private:
HashTableLink<NotificationService> fLink; NotificationService* fLink;
}; };
struct default_listener : public DoublyLinkedListLinkImpl<default_listener> { struct default_listener : public DoublyLinkedListLinkImpl<default_listener> {
@@ -226,11 +226,11 @@ private:
{ return hash_hash_string(service->Name()); } { return hash_hash_string(service->Name()); }
bool Compare(const char* key, NotificationService* service) const bool Compare(const char* key, NotificationService* service) const
{ return !strcmp(key, service->Name()); } { return !strcmp(key, service->Name()); }
HashTableLink<NotificationService>* GetLink( NotificationService*& GetLink(
NotificationService* service) const NotificationService* service) const
{ return &service->Link(); } { return service->Link(); }
}; };
typedef OpenHashTable<HashDefinition> ServiceHash; typedef BOpenHashTable<HashDefinition> ServiceHash;
static NotificationManager sManager; static NotificationManager sManager;
+2 -1
View File
@@ -46,7 +46,7 @@ private:
}; };
struct ConditionVariable : protected HashTableLink<ConditionVariable> { struct ConditionVariable {
public: public:
void Init(const void* object, void Init(const void* object,
const char* objectType); const char* objectType);
@@ -81,6 +81,7 @@ protected:
const void* fObject; const void* fObject;
const char* fObjectType; const char* fObjectType;
EntryList fEntries; EntryList fEntries;
ConditionVariable* fNext;
friend struct ConditionVariableEntry; friend struct ConditionVariableEntry;
friend struct ConditionVariableHashDefinition; friend struct ConditionVariableHashDefinition;
+1 -1
View File
@@ -18,7 +18,7 @@ struct team;
struct image { struct image {
struct image* next; struct image* next;
struct image* prev; struct image* prev;
HashTableLink<image> hash_link; struct image* hash_link;
image_info info; image_info info;
team_id team; team_id team;
}; };
+9 -9
View File
@@ -21,10 +21,10 @@
template<typename Definition, bool AutoExpand = true, template<typename Definition, bool AutoExpand = true,
bool CheckDuplicates = false> bool CheckDuplicates = false>
class MultiHashTable : private OpenHashTable<Definition, class MultiHashTable : private BOpenHashTable<Definition,
AutoExpand, CheckDuplicates> { AutoExpand, CheckDuplicates> {
public: public:
typedef OpenHashTable<Definition, AutoExpand, CheckDuplicates> HashTable; typedef BOpenHashTable<Definition, AutoExpand, CheckDuplicates> HashTable;
typedef MultiHashTable<Definition, AutoExpand, CheckDuplicates> MultiTable; typedef MultiHashTable<Definition, AutoExpand, CheckDuplicates> MultiTable;
typedef typename HashTable::Iterator Iterator; typedef typename HashTable::Iterator Iterator;
@@ -116,7 +116,7 @@ public:
while (slot) { while (slot) {
if (HashTable::fDefinition.Compare(key, slot)) if (HashTable::fDefinition.Compare(key, slot))
break; break;
slot = HashTable::_Link(slot)->fNext; slot = HashTable::_Link(slot);
} }
if (slot == NULL) if (slot == NULL)
@@ -140,18 +140,18 @@ private:
// group values with the same key // group values with the same key
for (previous = table[index]; previous for (previous = table[index]; previous
&& !HashTable::fDefinition.CompareValues(previous, value); && !HashTable::fDefinition.CompareValues(previous, value);
previous = HashTable::_Link(previous)->fNext); previous = HashTable::_Link(previous));
if (previous) { if (previous) {
_Link(value)->fNext = _Link(previous)->fNext; _Link(value) = _Link(previous);
_Link(previous)->fNext = value; _Link(previous) = value;
} else { } else {
_Link(value)->fNext = table[index]; _Link(value) = table[index];
table[index] = value; table[index] = value;
} }
} }
// TODO use OpenHashTable's _Resize // TODO use BOpenHashTable's _Resize
bool _Resize(size_t newSize) bool _Resize(size_t newSize)
{ {
ValueType **newTable = new ValueType *[newSize]; ValueType **newTable = new ValueType *[newSize];
@@ -165,7 +165,7 @@ private:
for (size_t i = 0; i < HashTable::fTableSize; i++) { for (size_t i = 0; i < HashTable::fTableSize; i++) {
ValueType *bucket = HashTable::fTable[i]; ValueType *bucket = HashTable::fTable[i];
while (bucket) { while (bucket) {
ValueType *next = _Link(bucket)->fNext; ValueType *next = _Link(bucket);
_Insert(newTable, newSize, bucket); _Insert(newTable, newSize, bucket);
bucket = next; bucket = next;
} }
+21 -23
View File
@@ -21,10 +21,10 @@
`Compare' and `GetLink;. It must also define several types as shown in the `Compare' and `GetLink;. It must also define several types as shown in the
following example: following example:
struct Foo : HashTableLink<Foo> { struct Foo {
int bar; int bar;
HashTableLink<Foo> otherLink; Foo* fNext;
}; };
struct HashTableDefinition { struct HashTableDefinition {
@@ -36,20 +36,16 @@
size_t HashKey(int key) const { return key >> 1; } size_t HashKey(int key) const { return key >> 1; }
size_t Hash(Foo* value) const { return HashKey(value->bar); } size_t Hash(Foo* value) const { return HashKey(value->bar); }
bool Compare(int key, Foo* value) const { return value->bar == key; } bool Compare(int key, Foo* value) const { return value->bar == key; }
HashTableLink<Foo> *GetLink(Foo *value) const { return value; } Foo*& GetLink(Foo* value) const { return value->fNext; }
}; };
*/ */
template<typename Type>
struct HashTableLink {
Type *fNext;
};
template<typename Definition, bool AutoExpand = true, template<typename Definition, bool AutoExpand = true,
bool CheckDuplicates = false> bool CheckDuplicates = false>
class OpenHashTable { class BOpenHashTable {
public: public:
typedef OpenHashTable<Definition, AutoExpand, CheckDuplicates> HashTable; typedef BOpenHashTable<Definition, AutoExpand, CheckDuplicates> HashTable;
typedef typename Definition::KeyType KeyType; typedef typename Definition::KeyType KeyType;
typedef typename Definition::ValueType ValueType; typedef typename Definition::ValueType ValueType;
@@ -62,7 +58,7 @@ public:
// regrowth factor: 200 / 256 = 78.125% // regrowth factor: 200 / 256 = 78.125%
// 50 / 256 = 19.53125% // 50 / 256 = 19.53125%
OpenHashTable() BOpenHashTable()
: :
fTableSize(0), fTableSize(0),
fItemCount(0), fItemCount(0),
@@ -70,7 +66,7 @@ public:
{ {
} }
OpenHashTable(const Definition& definition) BOpenHashTable(const Definition& definition)
: :
fDefinition(definition), fDefinition(definition),
fTableSize(0), fTableSize(0),
@@ -79,7 +75,7 @@ public:
{ {
} }
~OpenHashTable() ~BOpenHashTable()
{ {
free(fTable); free(fTable);
} }
@@ -112,7 +108,7 @@ public:
while (slot) { while (slot) {
if (fDefinition.Compare(key, slot)) if (fDefinition.Compare(key, slot))
break; break;
slot = _Link(slot)->fNext; slot = _Link(slot);
} }
return slot; return slot;
@@ -161,14 +157,15 @@ public:
bool RemoveUnchecked(ValueType* value) bool RemoveUnchecked(ValueType* value)
{ {
size_t index = fDefinition.Hash(value) & (fTableSize - 1); size_t index = fDefinition.Hash(value) & (fTableSize - 1);
ValueType *previous = NULL, *slot = fTable[index]; ValueType* previous = NULL;
ValueType* slot = fTable[index];
while (slot) { while (slot) {
ValueType *next = _Link(slot)->fNext; ValueType* next = _Link(slot);
if (value == slot) { if (value == slot) {
if (previous) if (previous)
_Link(previous)->fNext = next; _Link(previous) = next;
else else
fTable[index] = next; fTable[index] = next;
break; break;
@@ -217,7 +214,7 @@ public:
// update nextPointer to point to the fNext of the last // update nextPointer to point to the fNext of the last
// element in the bucket // element in the bucket
while (element != NULL) { while (element != NULL) {
nextPointer = &_Link(element)->fNext; nextPointer = &_Link(element);
element = *nextPointer; element = *nextPointer;
} }
} }
@@ -306,7 +303,7 @@ public:
void _GetNext() void _GetNext()
{ {
if (fNext) if (fNext)
fNext = fTable->_Link(fNext)->fNext; fNext = fTable->_Link(fNext);
while (fNext == NULL && fIndex < fTable->fTableSize) while (fNext == NULL && fIndex < fTable->fTableSize)
fNext = fTable->fTable[fIndex++]; fNext = fTable->fTable[fIndex++];
@@ -327,7 +324,7 @@ protected:
{ {
size_t index = fDefinition.Hash(value) & (tableSize - 1); size_t index = fDefinition.Hash(value) & (tableSize - 1);
_Link(value)->fNext = table[index]; _Link(value) = table[index];
table[index] = value; table[index] = value;
} }
@@ -351,7 +348,7 @@ protected:
for (size_t i = 0; i < fTableSize; i++) { for (size_t i = 0; i < fTableSize; i++) {
ValueType* bucket = fTable[i]; ValueType* bucket = fTable[i];
while (bucket) { while (bucket) {
ValueType *next = _Link(bucket)->fNext; ValueType* next = _Link(bucket);
_Insert(newTable, newSize, bucket); _Insert(newTable, newSize, bucket);
bucket = next; bucket = next;
} }
@@ -364,7 +361,7 @@ protected:
fTable = newTable; fTable = newTable;
} }
HashTableLink<ValueType> *_Link(ValueType *bucket) const ValueType*& _Link(ValueType* bucket) const
{ {
return fDefinition.GetLink(bucket); return fDefinition.GetLink(bucket);
} }
@@ -376,7 +373,7 @@ protected:
while (bucket) { while (bucket) {
if (bucket == value) if (bucket == value)
return true; return true;
bucket = _Link(bucket)->fNext; bucket = _Link(bucket);
} }
} }
@@ -384,7 +381,8 @@ protected:
} }
Definition fDefinition; Definition fDefinition;
size_t fTableSize, fItemCount; size_t fTableSize;
size_t fItemCount;
ValueType** fTable; ValueType** fTable;
}; };
+7 -5
View File
@@ -15,7 +15,7 @@
// HashMapElement // HashMapElement
template<typename Key, typename Value> template<typename Key, typename Value>
class HashMapElement : public HashTableLink<HashMapElement<Key, Value> > { class HashMapElement {
private: private:
typedef HashMapElement<Key, Value> Element; typedef HashMapElement<Key, Value> Element;
@@ -36,6 +36,7 @@ public:
Key fKey; Key fKey;
Value fValue; Value fValue;
HashMapElement* fNext;
}; };
@@ -51,8 +52,8 @@ struct HashMapTableDefinition {
{ return HashKey(value->fKey); } { return HashKey(value->fKey); }
bool Compare(const KeyType& key, const ValueType* value) const bool Compare(const KeyType& key, const ValueType* value) const
{ return value->fKey == key; } { return value->fKey == key; }
HashTableLink<ValueType>* GetLink(ValueType* value) const ValueType*& GetLink(ValueType* value) const
{ return value; } { return value->fNext; }
}; };
@@ -128,7 +129,8 @@ public:
private: private:
friend class HashMap<Key, Value>; friend class HashMap<Key, Value>;
typedef OpenHashTable<HashMapTableDefinition<Key, Value> > ElementTable; typedef BOpenHashTable<HashMapTableDefinition<Key, Value> >
ElementTable;
HashMap<Key, Value>* fMap; HashMap<Key, Value>* fMap;
typename ElementTable::Iterator fIterator; typename ElementTable::Iterator fIterator;
@@ -152,7 +154,7 @@ public:
Iterator GetIterator(); Iterator GetIterator();
protected: protected:
typedef OpenHashTable<HashMapTableDefinition<Key, Value> > ElementTable; typedef BOpenHashTable<HashMapTableDefinition<Key, Value> > ElementTable;
typedef HashMapElement<Key, Value> Element; typedef HashMapElement<Key, Value> Element;
friend class Iterator; friend class Iterator;
@@ -74,8 +74,9 @@
#define BIND_APERTURE 0x20000000 #define BIND_APERTURE 0x20000000
#define APERTURE_PUBLIC_FLAGS_MASK 0x0000ffff #define APERTURE_PUBLIC_FLAGS_MASK 0x0000ffff
struct aperture_memory : HashTableLink<aperture_memory> { struct aperture_memory {
aperture_memory *next; aperture_memory *next;
aperture_memory *hash_link;
addr_t base; addr_t base;
size_t size; size_t size;
uint32 flags; uint32 flags;
@@ -104,21 +105,21 @@ public:
{ return (memory->base - fInfo.base) / B_PAGE_SIZE; } { return (memory->base - fInfo.base) / B_PAGE_SIZE; }
bool Compare(const KeyType &base, aperture_memory *memory) const bool Compare(const KeyType &base, aperture_memory *memory) const
{ return base == memory->base; } { return base == memory->base; }
HashTableLink<aperture_memory> *GetLink(aperture_memory *memory) const aperture_memory *&GetLink(aperture_memory *memory) const
{ return memory; } { return memory->hash_link; }
private: private:
aperture_info &fInfo; aperture_info &fInfo;
}; };
typedef OpenHashTable<MemoryHashDefinition> MemoryHashTable; typedef BOpenHashTable<MemoryHashDefinition> MemoryHashTable;
struct agp_device_info { struct agp_device_info {
uint8 address; /* location of AGP interface in PCI capabilities */ uint8 address; /* location of AGP interface in PCI capabilities */
agp_info info; agp_info info;
}; };
class Aperture : public HashTableLink<Aperture> { class Aperture {
public: public:
Aperture(agp_gart_bus_module_info *module, void *aperture); Aperture(agp_gart_bus_module_info *module, void *aperture);
~Aperture(); ~Aperture();
@@ -156,6 +157,9 @@ private:
MemoryHashTable fHashTable; MemoryHashTable fHashTable;
aperture_memory *fFirstMemory; aperture_memory *fFirstMemory;
void *fPrivateAperture; void *fPrivateAperture;
public:
Aperture *fNext;
}; };
class ApertureHashDefinition { class ApertureHashDefinition {
@@ -169,11 +173,11 @@ public:
{ return aperture->ID(); } { return aperture->ID(); }
bool Compare(const KeyType &id, Aperture *aperture) const bool Compare(const KeyType &id, Aperture *aperture) const
{ return id == aperture->ID(); } { return id == aperture->ID(); }
HashTableLink<Aperture> *GetLink(Aperture *aperture) const Aperture *&GetLink(Aperture *aperture) const
{ return aperture; } { return aperture->fNext; }
}; };
typedef OpenHashTable<ApertureHashDefinition> ApertureHashTable; typedef BOpenHashTable<ApertureHashDefinition> ApertureHashTable;
static agp_device_info sDeviceInfos[MAX_DEVICES]; static agp_device_info sDeviceInfos[MAX_DEVICES];
@@ -76,7 +76,7 @@ FileSystem::~FileSystem()
int32 count = 0; int32 count = 0;
while (ops != NULL) { while (ops != NULL) {
count++; count++;
VNodeOps* next = ops->fNext; VNodeOps* next = ops->hash_link;
free(ops); free(ops);
ops = next; ops = next;
} }
@@ -25,10 +25,11 @@ class Settings;
class Volume; class Volume;
struct VNodeOps : HashTableLink<VNodeOps> { struct VNodeOps {
int32 refCount; int32 refCount;
FSVNodeCapabilities capabilities; FSVNodeCapabilities capabilities;
fs_vnode_ops* ops; fs_vnode_ops* ops;
VNodeOps* hash_link;
VNodeOps(const FSVNodeCapabilities& capabilities, fs_vnode_ops* ops) VNodeOps(const FSVNodeCapabilities& capabilities, fs_vnode_ops* ops)
: :
@@ -55,8 +56,8 @@ struct VNodeOpsHashDefinition {
{ return HashKey(value->capabilities); } { return HashKey(value->capabilities); }
bool Compare(const FSVNodeCapabilities& key, const VNodeOps* value) const bool Compare(const FSVNodeCapabilities& key, const VNodeOps* value) const
{ return value->capabilities == key; } { return value->capabilities == key; }
HashTableLink<VNodeOps>* GetLink(VNodeOps* value) const VNodeOps*& GetLink(VNodeOps* value) const
{ return value; } { return value->hash_link; }
}; };
@@ -109,7 +110,7 @@ private:
friend class KernelDebug; friend class KernelDebug;
struct SelectSyncEntry; struct SelectSyncEntry;
struct SelectSyncMap; struct SelectSyncMap;
typedef OpenHashTable<VNodeOpsHashDefinition> VNodeOpsMap; typedef BOpenHashTable<VNodeOpsHashDefinition> VNodeOpsMap;
Vector<Volume*> fVolumes; Vector<Volume*> fVolumes;
mutex fVolumeLock; mutex fVolumeLock;
@@ -47,7 +47,7 @@ static const bigtime_t kUserlandServerlandPortTimeout = 10000000; // 10s
// VNode // VNode
struct Volume::VNode : HashTableLink<VNode> { struct Volume::VNode {
ino_t id; ino_t id;
void* clientNode; void* clientNode;
void* fileCache; void* fileCache;
@@ -55,6 +55,7 @@ struct Volume::VNode : HashTableLink<VNode> {
int32 useCount; int32 useCount;
bool valid; bool valid;
bool published; bool published;
VNode* hash_link;
VNode(ino_t id, void* clientNode, VNodeOps* ops) VNode(ino_t id, void* clientNode, VNodeOps* ops)
: :
@@ -98,14 +99,14 @@ struct Volume::VNodeHashDefinition {
{ return HashKey(value->id); } { return HashKey(value->id); }
bool Compare(ino_t key, const VNode* value) const bool Compare(ino_t key, const VNode* value) const
{ return value->id == key; } { return value->id == key; }
HashTableLink<VNode>* GetLink(VNode* value) const VNode*& GetLink(VNode* value) const
{ return value; } { return value->hash_link; }
}; };
// VNodeMap // VNodeMap
struct Volume::VNodeMap struct Volume::VNodeMap
: public OpenHashTable<VNodeHashDefinition> { : public BOpenHashTable<VNodeHashDefinition> {
}; };
@@ -114,8 +115,8 @@ struct Volume::IORequestInfo {
io_request* request; io_request* request;
int32 id; int32 id;
HashTableLink<IORequestInfo> idLink; IORequestInfo* idLink;
HashTableLink<IORequestInfo> structLink; IORequestInfo* structLink;
IORequestInfo(io_request* request, int32 id) IORequestInfo(io_request* request, int32 id)
: :
@@ -137,8 +138,8 @@ struct Volume::IORequestIDHashDefinition {
{ return HashKey(value->id); } { return HashKey(value->id); }
bool Compare(int32 key, const IORequestInfo* value) const bool Compare(int32 key, const IORequestInfo* value) const
{ return value->id == key; } { return value->id == key; }
HashTableLink<IORequestInfo>* GetLink(IORequestInfo* value) const IORequestInfo*& GetLink(IORequestInfo* value) const
{ return &value->idLink; } { return value->idLink; }
}; };
@@ -153,20 +154,20 @@ struct Volume::IORequestStructHashDefinition {
{ return HashKey(value->request); } { return HashKey(value->request); }
bool Compare(io_request* key, const IORequestInfo* value) const bool Compare(io_request* key, const IORequestInfo* value) const
{ return value->request == key; } { return value->request == key; }
HashTableLink<IORequestInfo>* GetLink(IORequestInfo* value) const IORequestInfo*& GetLink(IORequestInfo* value) const
{ return &value->structLink; } { return value->structLink; }
}; };
// IORequestIDMap // IORequestIDMap
struct Volume::IORequestIDMap struct Volume::IORequestIDMap
: public OpenHashTable<IORequestIDHashDefinition> { : public BOpenHashTable<IORequestIDHashDefinition> {
}; };
// IORequestStructMap // IORequestStructMap
struct Volume::IORequestStructMap struct Volume::IORequestStructMap
: public OpenHashTable<IORequestStructHashDefinition> { : public BOpenHashTable<IORequestStructHashDefinition> {
}; };
@@ -802,7 +803,7 @@ Volume::Unmount()
if (fVNodes != NULL) { if (fVNodes != NULL) {
VNode* node = fVNodes->Clear(true); VNode* node = fVNodes->Clear(true);
while (node != NULL) { while (node != NULL) {
VNode* nextNode = node->fNext; VNode* nextNode = node->hash_link;
node->Delete(this); node->Delete(this);
node = nextNode; node = nextNode;
} }
@@ -820,7 +821,7 @@ Volume::Unmount()
if (fIORequestInfosByStruct != NULL) { if (fIORequestInfosByStruct != NULL) {
IORequestInfo* info = fIORequestInfosByStruct->Clear(true); IORequestInfo* info = fIORequestInfosByStruct->Clear(true);
while (info != NULL) { while (info != NULL) {
IORequestInfo* nextInfo = info->structLink.fNext; IORequestInfo* nextInfo = info->structLink;
delete info; delete info;
info = nextInfo; info = nextInfo;
} }
@@ -35,11 +35,11 @@ struct FUSEEntryRef {
}; };
struct FUSEEntry : public HashTableLink<FUSEEntry>, struct FUSEEntry : DoublyLinkedListLinkImpl<FUSEEntry> {
DoublyLinkedListLinkImpl<FUSEEntry> {
FUSENode* parent; FUSENode* parent;
char* name; char* name;
FUSENode* node; FUSENode* node;
FUSEEntry* hashLink;
FUSEEntry() FUSEEntry()
: :
@@ -77,12 +77,13 @@ struct FUSEEntry : public HashTableLink<FUSEEntry>,
typedef DoublyLinkedList<FUSEEntry> FUSEEntryList; typedef DoublyLinkedList<FUSEEntry> FUSEEntryList;
struct FUSENode : RWLockable, HashTableLink<FUSENode> { struct FUSENode : RWLockable {
ino_t id; ino_t id;
FUSEEntryList entries; FUSEEntryList entries;
int type; int type;
int32 refCount; int32 refCount;
bool dirty; bool dirty;
FUSENode* hashLink;
FUSENode(ino_t id, int type) FUSENode(ino_t id, int type)
: :
@@ -113,8 +114,8 @@ struct FUSEEntryHashDefinition {
bool Compare(const FUSEEntryRef& key, const FUSEEntry* value) const bool Compare(const FUSEEntryRef& key, const FUSEEntry* value) const
{ return value->parent->id == key.parentID { return value->parent->id == key.parentID
&& strcmp(value->name, key.name) == 0; } && strcmp(value->name, key.name) == 0; }
HashTableLink<FUSEEntry>* GetLink(FUSEEntry* value) const FUSEEntry*& GetLink(FUSEEntry* value) const
{ return value; } { return value->hashLink; }
}; };
@@ -128,13 +129,13 @@ struct FUSENodeHashDefinition {
{ return HashKey(value->id); } { return HashKey(value->id); }
bool Compare(ino_t key, const FUSENode* value) const bool Compare(ino_t key, const FUSENode* value) const
{ return value->id == key; } { return value->id == key; }
HashTableLink<FUSENode>* GetLink(FUSENode* value) const FUSENode*& GetLink(FUSENode* value) const
{ return value; } { return value->hashLink; }
}; };
typedef OpenHashTable<FUSEEntryHashDefinition> FUSEEntryTable; typedef BOpenHashTable<FUSEEntryHashDefinition> FUSEEntryTable;
typedef OpenHashTable<FUSENodeHashDefinition> FUSENodeTable; typedef BOpenHashTable<FUSENodeHashDefinition> FUSENodeTable;
} // namespace UserlandFS } // namespace UserlandFS
@@ -32,15 +32,14 @@ struct HaikuKernelFileSystem::IORequestHashDefinition {
{ return value->id; } { return value->id; }
bool Compare(int32 key, const HaikuKernelIORequest* value) const bool Compare(int32 key, const HaikuKernelIORequest* value) const
{ return value->id == key; } { return value->id == key; }
HashTableLink<HaikuKernelIORequest>* HaikuKernelIORequest*& GetLink(HaikuKernelIORequest* value) const
GetLink(HaikuKernelIORequest* value) const { return value->hashLink; }
{ return value; }
}; };
// IORequestTable // IORequestTable
struct HaikuKernelFileSystem::IORequestTable struct HaikuKernelFileSystem::IORequestTable
: public OpenHashTable<IORequestHashDefinition> { : public BOpenHashTable<IORequestHashDefinition> {
typedef int32 KeyType; typedef int32 KeyType;
typedef HaikuKernelIORequest ValueType; typedef HaikuKernelIORequest ValueType;
@@ -50,9 +49,8 @@ struct HaikuKernelFileSystem::IORequestTable
{ return value->id; } { return value->id; }
bool Compare(int32 key, const HaikuKernelIORequest* value) const bool Compare(int32 key, const HaikuKernelIORequest* value) const
{ return value->id == key; } { return value->id == key; }
HashTableLink<HaikuKernelIORequest>* HaikuKernelIORequest*& GetLink(HaikuKernelIORequest* value) const
GetLink(HaikuKernelIORequest* value) const { return value->hashLink; }
{ return value; }
}; };
@@ -67,14 +65,14 @@ struct HaikuKernelFileSystem::NodeCapabilitiesHashDefinition {
{ return HashKey(value->ops); } { return HashKey(value->ops); }
bool Compare(fs_vnode_ops* key, const ValueType* value) const bool Compare(fs_vnode_ops* key, const ValueType* value) const
{ return value->ops == key; } { return value->ops == key; }
HashTableLink<ValueType>* GetLink(ValueType* value) const ValueType*& GetLink(ValueType* value) const
{ return value; } { return value->hashLink; }
}; };
// NodeCapabilitiesTable // NodeCapabilitiesTable
struct HaikuKernelFileSystem::NodeCapabilitiesTable struct HaikuKernelFileSystem::NodeCapabilitiesTable
: public OpenHashTable<NodeCapabilitiesHashDefinition> { : public BOpenHashTable<NodeCapabilitiesHashDefinition> {
}; };
@@ -16,11 +16,11 @@ namespace UserlandFS {
class HaikuKernelVolume; class HaikuKernelVolume;
struct HaikuKernelIORequest : HashTableLink<HaikuKernelIORequest>, struct HaikuKernelIORequest : IORequestInfo {
IORequestInfo {
HaikuKernelVolume* volume; HaikuKernelVolume* volume;
int32 refCount; int32 refCount;
HaikuKernelIORequest* hashLink;
HaikuKernelIORequest(HaikuKernelVolume* volume, const IORequestInfo& info) HaikuKernelIORequest(HaikuKernelVolume* volume, const IORequestInfo& info)
: :
@@ -41,10 +41,11 @@ public:
}; };
struct HaikuKernelNode::Capabilities : HashTableLink<Capabilities> { struct HaikuKernelNode::Capabilities {
int32 refCount; int32 refCount;
fs_vnode_ops* ops; fs_vnode_ops* ops;
FSVNodeCapabilities capabilities; FSVNodeCapabilities capabilities;
Capabilities* hashLink;
Capabilities(fs_vnode_ops* ops, FSVNodeCapabilities capabilities) Capabilities(fs_vnode_ops* ops, FSVNodeCapabilities capabilities)
: :
@@ -150,7 +150,7 @@ struct MulticastStateHash {
bool CompareValues(ValueType* value1, ValueType* value2) const bool CompareValues(ValueType* value1, ValueType* value2) const
{ return value1->Interface()->index == value2->Interface()->index { return value1->Interface()->index == value2->Interface()->index
&& value1->Address().s_addr == value2->Address().s_addr; } && value1->Address().s_addr == value2->Address().s_addr; }
HashTableLink<ValueType>* GetLink(ValueType* value) const { return value; } ValueType*& GetLink(ValueType* value) const { return value->HashLink(); }
}; };
@@ -126,11 +126,9 @@ private:
template<typename Addressing> template<typename Addressing>
class MulticastGroupInterface class MulticastGroupInterface {
: public HashTableLink< MulticastGroupInterface<Addressing> > {
public: public:
typedef MulticastGroupInterface<Addressing> ThisType; typedef MulticastGroupInterface<Addressing> ThisType;
typedef HashTableLink<ThisType> HashLink;
typedef typename Addressing::AddressType AddressType; typedef typename Addressing::AddressType AddressType;
typedef MulticastFilter<Addressing> Filter; typedef MulticastFilter<Addressing> Filter;
typedef ::AddressSet<AddressType> AddressSet; typedef ::AddressSet<AddressType> AddressSet;
@@ -176,9 +174,12 @@ public:
bool Compare(const KeyType &key, ValueType *value) const bool Compare(const KeyType &key, ValueType *value) const
{ return value->Interface()->index == key.second { return value->Interface()->index == key.second
&& value->Address().s_addr == key.first->s_addr; } && value->Address().s_addr == key.first->s_addr; }
HashLink *GetLink(ValueType *value) const { return &value->fLink; } MulticastGroupInterface*& GetLink(ValueType *value) const
{ return value->HashLink(); }
}; };
MulticastGroupInterface*& HashLink() { return fLink; }
private: private:
// for g++ 2.95 // for g++ 2.95
friend class HashDefinition; friend class HashDefinition;
@@ -188,7 +189,7 @@ private:
net_interface *fInterface; net_interface *fInterface;
FilterMode fFilterMode; FilterMode fFilterMode;
AddressSet fAddresses; AddressSet fAddresses;
HashLink fLink; MulticastGroupInterface* fLink;
}; };
template<typename Addressing> template<typename Addressing>
@@ -209,7 +210,7 @@ public:
private: private:
typedef typename GroupInterface::HashDefinition HashDefinition; typedef typename GroupInterface::HashDefinition HashDefinition;
typedef OpenHashTable<HashDefinition> States; typedef BOpenHashTable<HashDefinition> States;
void _ReturnState(GroupInterface *state); void _ReturnState(GroupInterface *state);
@@ -165,10 +165,10 @@ ConnectionHashDefinition::Compare(const KeyType& key,
} }
HashTableLink<TCPEndpoint>* TCPEndpoint*&
ConnectionHashDefinition::GetLink(TCPEndpoint* endpoint) const ConnectionHashDefinition::GetLink(TCPEndpoint* endpoint) const
{ {
return &endpoint->fConnectionHashLink; return endpoint->fConnectionHashLink;
} }
@@ -204,10 +204,10 @@ EndpointHashDefinition::CompareValues(TCPEndpoint* first,
} }
HashTableLink<TCPEndpoint>* TCPEndpoint*&
EndpointHashDefinition::GetLink(TCPEndpoint* endpoint) const EndpointHashDefinition::GetLink(TCPEndpoint* endpoint) const
{ {
return &endpoint->fEndpointHashLink; return endpoint->fEndpointHashLink;
} }
@@ -45,7 +45,7 @@ public:
size_t Hash(TCPEndpoint* endpoint) const; size_t Hash(TCPEndpoint* endpoint) const;
bool Compare(const KeyType& key, bool Compare(const KeyType& key,
TCPEndpoint* endpoint) const; TCPEndpoint* endpoint) const;
HashTableLink<TCPEndpoint>* GetLink(TCPEndpoint* endpoint) const; TCPEndpoint*& GetLink(TCPEndpoint* endpoint) const;
private: private:
EndpointManager* fManager; EndpointManager* fManager;
@@ -62,7 +62,7 @@ public:
bool Compare(uint16 port, TCPEndpoint* endpoint) const; bool Compare(uint16 port, TCPEndpoint* endpoint) const;
bool CompareValues(TCPEndpoint* first, bool CompareValues(TCPEndpoint* first,
TCPEndpoint* second) const; TCPEndpoint* second) const;
HashTableLink<TCPEndpoint>* GetLink(TCPEndpoint* endpoint) const; TCPEndpoint*& GetLink(TCPEndpoint* endpoint) const;
}; };
@@ -104,7 +104,7 @@ private:
status_t _BindToEphemeral(TCPEndpoint* endpoint, status_t _BindToEphemeral(TCPEndpoint* endpoint,
const sockaddr* address); const sockaddr* address);
typedef OpenHashTable<ConnectionHashDefinition> ConnectionTable; typedef BOpenHashTable<ConnectionHashDefinition> ConnectionTable;
typedef MultiHashTable<EndpointHashDefinition> EndpointTable; typedef MultiHashTable<EndpointHashDefinition> EndpointTable;
rw_lock fLock; rw_lock fLock;
@@ -133,8 +133,8 @@ private:
void* _endpoint); void* _endpoint);
private: private:
HashTableLink<TCPEndpoint> fConnectionHashLink; TCPEndpoint* fConnectionHashLink;
HashTableLink<TCPEndpoint> fEndpointHashLink; TCPEndpoint* fEndpointHashLink;
friend class EndpointManager; friend class EndpointManager;
friend class ConnectionHashDefinition; friend class ConnectionHashDefinition;
friend class EndpointHashDefinition; friend class EndpointHashDefinition;
@@ -96,7 +96,7 @@ public:
bool IsActive() const { return fActive; } bool IsActive() const { return fActive; }
void SetActive(bool newValue) { fActive = newValue; } void SetActive(bool newValue) { fActive = newValue; }
::HashTableLink<UdpEndpoint> *HashTableLink() { return &fLink; } UdpEndpoint *&HashTableLink() { return fLink; }
private: private:
UdpDomainSupport *fManager; UdpDomainSupport *fManager;
@@ -104,7 +104,7 @@ private:
// an active UdpEndpoint is part of the endpoint // an active UdpEndpoint is part of the endpoint
// hash (and it is bound and optionally connected) // hash (and it is bound and optionally connected)
::HashTableLink<UdpEndpoint> fLink; UdpEndpoint *fLink;
}; };
@@ -143,7 +143,7 @@ struct UdpHashDefinition {
&& endpoint->PeerAddress().EqualTo(key.second, true); && endpoint->PeerAddress().EqualTo(key.second, true);
} }
::HashTableLink<UdpEndpoint> *GetLink(UdpEndpoint *endpoint) const UdpEndpoint *&GetLink(UdpEndpoint *endpoint) const
{ {
return endpoint->HashTableLink(); return endpoint->HashTableLink();
} }
@@ -189,7 +189,7 @@ private:
net_address_module_info *AddressModule() const net_address_module_info *AddressModule() const
{ return fDomain->address_module; } { return fDomain->address_module; }
typedef OpenHashTable<UdpHashDefinition, false> EndpointTable; typedef BOpenHashTable<UdpHashDefinition, false> EndpointTable;
mutex fLock; mutex fLock;
net_domain *fDomain; net_domain *fDomain;
@@ -31,7 +31,7 @@ struct UnixAddressHashDefinition {
return key == endpoint->Address(); return key == endpoint->Address();
} }
HashTableLink<UnixEndpoint>* GetLink(UnixEndpoint* endpoint) const UnixEndpoint*& GetLink(UnixEndpoint* endpoint) const
{ {
return endpoint->HashTableLink(); return endpoint->HashTableLink();
} }
@@ -100,7 +100,7 @@ public:
} }
private: private:
typedef OpenHashTable<UnixAddressHashDefinition, false> EndpointTable; typedef BOpenHashTable<UnixAddressHashDefinition, false> EndpointTable;
mutex fLock; mutex fLock;
EndpointTable fBoundEndpoints; EndpointTable fBoundEndpoints;
@@ -90,9 +90,9 @@ public:
return fAddress; return fAddress;
} }
::HashTableLink<UnixEndpoint>* HashTableLink() UnixEndpoint*& HashTableLink()
{ {
return &fAddressHashLink; return fAddressHashLink;
} }
private: private:
@@ -112,7 +112,7 @@ private:
private: private:
mutex fLock; mutex fLock;
UnixAddress fAddress; UnixAddress fAddress;
::HashTableLink<UnixEndpoint> fAddressHashLink; UnixEndpoint* fAddressHashLink;
UnixEndpoint* fPeerEndpoint; UnixEndpoint* fPeerEndpoint;
UnixFifo* fReceiveFifo; UnixFifo* fReceiveFifo;
unix_endpoint_state fState; unix_endpoint_state fState;
+4 -1
View File
@@ -34,7 +34,7 @@ private:
}; };
class SubWindow : public BWindow, public HashTableLink<SubWindow> { class SubWindow : public BWindow {
public: public:
SubWindow(SubWindowManager* manager, SubWindow(SubWindowManager* manager,
BRect frame, const char* title, BRect frame, const char* title,
@@ -50,6 +50,9 @@ public:
protected: protected:
SubWindowManager* fSubWindowManager; SubWindowManager* fSubWindowManager;
SubWindowKey* fSubWindowKey; SubWindowKey* fSubWindowKey;
public:
SubWindow* fNext;
}; };
@@ -49,13 +49,13 @@ private:
return key.Equals(value->GetSubWindowKey()); return key.Equals(value->GetSubWindowKey());
} }
HashTableLink<SubWindow>* GetLink(SubWindow* value) const SubWindow*& GetLink(SubWindow* value) const
{ {
return value; return value->fNext;
} }
}; };
typedef OpenHashTable<HashDefinition> SubWindowTable; typedef BOpenHashTable<HashDefinition> SubWindowTable;
private: private:
BLooper* fParent; BLooper* fParent;
@@ -130,7 +130,7 @@ ModelLoader::FinishLoading(bool success)
{ {
ThreadInfo* threadInfo = fThreads.Clear(true); ThreadInfo* threadInfo = fThreads.Clear(true);
while (threadInfo != NULL) { while (threadInfo != NULL) {
ThreadInfo* nextInfo = threadInfo->fNext; ThreadInfo* nextInfo = threadInfo->next;
delete threadInfo; delete threadInfo;
threadInfo = nextInfo; threadInfo = nextInfo;
} }
@@ -44,11 +44,12 @@ private:
UNKNOWN UNKNOWN
}; };
struct ThreadInfo : HashTableLink<ThreadInfo> { struct ThreadInfo {
Model::Thread* thread; Model::Thread* thread;
ScheduleState state; ScheduleState state;
bigtime_t lastTime; bigtime_t lastTime;
Model::ThreadWaitObject* waitObject; Model::ThreadWaitObject* waitObject;
ThreadInfo* next;
ThreadInfo(Model::Thread* thread); ThreadInfo(Model::Thread* thread);
@@ -68,11 +69,11 @@ private:
bool Compare(thread_id key, const ThreadInfo* value) const bool Compare(thread_id key, const ThreadInfo* value) const
{ return key == value->ID(); } { return key == value->ID(); }
HashTableLink<ThreadInfo>* GetLink(ThreadInfo* value) const ThreadInfo*& GetLink(ThreadInfo* value) const
{ return value; } { return value->next; }
}; };
typedef OpenHashTable<ThreadTableDefinition> ThreadTable; typedef BOpenHashTable<ThreadTableDefinition> ThreadTable;
// shorthands for the longish structure names // shorthands for the longish structure names
typedef system_profiler_thread_enqueued_in_run_queue typedef system_profiler_thread_enqueued_in_run_queue
+6 -3
View File
@@ -44,7 +44,7 @@
struct TeamDebugger::ImageHandler : public Referenceable, struct TeamDebugger::ImageHandler : public Referenceable,
public HashTableLink<ImageHandler>, private LocatableFile::Listener { private LocatableFile::Listener {
public: public:
ImageHandler(TeamDebugger* teamDebugger, Image* image) ImageHandler(TeamDebugger* teamDebugger, Image* image)
: :
@@ -85,6 +85,9 @@ private:
private: private:
TeamDebugger* fTeamDebugger; TeamDebugger* fTeamDebugger;
Image* fImage; Image* fImage;
public:
ImageHandler* fNext;
}; };
@@ -110,9 +113,9 @@ struct TeamDebugger::ImageHandlerHashDefinition {
return value->ImageID() == key; return value->ImageID() == key;
} }
HashTableLink<ImageHandler>* GetLink(ImageHandler* value) const ImageHandler*& GetLink(ImageHandler* value) const
{ {
return value; return value->fNext;
} }
}; };
+1 -1
View File
@@ -74,7 +74,7 @@ private:
private: private:
struct ImageHandler; struct ImageHandler;
struct ImageHandlerHashDefinition; struct ImageHandlerHashDefinition;
typedef OpenHashTable<ImageHandlerHashDefinition> ImageHandlerTable; typedef BOpenHashTable<ImageHandlerHashDefinition> ImageHandlerTable;
private: private:
static status_t _DebugEventListenerEntry(void* data); static status_t _DebugEventListenerEntry(void* data);
+7 -5
View File
@@ -22,8 +22,7 @@ class Statement;
class Worker; class Worker;
class ThreadHandler : public Referenceable, class ThreadHandler : public Referenceable, private ImageDebugInfoProvider,
public HashTableLink<ThreadHandler>, private ImageDebugInfoProvider,
private BreakpointClient { private BreakpointClient {
public: public:
ThreadHandler(Thread* thread, Worker* worker, ThreadHandler(Thread* thread, Worker* worker,
@@ -98,6 +97,9 @@ private:
target_addr_t fBreakpointAddress; target_addr_t fBreakpointAddress;
target_addr_t fPreviousInstructionPointer; target_addr_t fPreviousInstructionPointer;
bool fSingleStepping; bool fSingleStepping;
public:
ThreadHandler* fNext;
}; };
@@ -120,13 +122,13 @@ struct ThreadHandlerHashDefinition {
return value->ThreadID() == key; return value->ThreadID() == key;
} }
HashTableLink<ThreadHandler>* GetLink(ThreadHandler* value) const ThreadHandler*& GetLink(ThreadHandler* value) const
{ {
return value; return value->fNext;
} }
}; };
typedef OpenHashTable<ThreadHandlerHashDefinition> ThreadHandlerTable; typedef BOpenHashTable<ThreadHandlerHashDefinition> ThreadHandlerTable;
#endif // THREAD_HANDLER_H #endif // THREAD_HANDLER_H
+1 -1
View File
@@ -241,7 +241,7 @@ Worker::ShutDown()
// abort all jobs // abort all jobs
Job* job = fJobs.Clear(true); Job* job = fJobs.Clear(true);
while (job != NULL) { while (job != NULL) {
Job* nextJob = static_cast<HashTableLink<Job>*>(job)->fNext; Job* nextJob = job->fNext;
_AbortJob(job, false); _AbortJob(job, false);
job = nextJob; job = nextJob;
+7 -5
View File
@@ -75,8 +75,7 @@ public:
typedef DoublyLinkedList<Job> JobList; typedef DoublyLinkedList<Job> JobList;
class Job : public Referenceable, public DoublyLinkedListLinkImpl<Job>, class Job : public Referenceable, public DoublyLinkedListLinkImpl<Job> {
public HashTableLink<Job> {
public: public:
Job(); Job();
virtual ~Job(); virtual ~Job();
@@ -119,6 +118,9 @@ private:
JobList fDependentJobs; JobList fDependentJobs;
job_wait_status fWaitStatus; job_wait_status fWaitStatus;
ListenerList fListeners; ListenerList fListeners;
public:
Job* fNext;
}; };
@@ -166,13 +168,13 @@ private:
return value->Key() == key; return value->Key() == key;
} }
HashTableLink<Job>* GetLink(Job* value) const Job*& GetLink(Job* value) const
{ {
return value; return value->fNext;
} }
}; };
typedef OpenHashTable<JobHashDefinition> JobTable; typedef BOpenHashTable<JobHashDefinition> JobTable;
private: private:
job_wait_status WaitForJob(Job* waitingJob, const JobKey& key); job_wait_status WaitForJob(Job* waitingJob, const JobKey& key);
@@ -115,8 +115,7 @@ private:
// #pragma mark - DwarfType // #pragma mark - DwarfType
struct DwarfInterfaceFactory::DwarfType : virtual Type, struct DwarfInterfaceFactory::DwarfType : virtual Type {
HashTableLink<DwarfType> {
public: public:
DwarfType(const BString& name) DwarfType(const BString& name)
: :
@@ -145,6 +144,9 @@ public:
private: private:
BString fName; BString fName;
uint64 fByteSize; uint64 fByteSize;
public:
DwarfType* fNext;
}; };
@@ -487,9 +489,9 @@ struct DwarfInterfaceFactory::DwarfTypeHashDefinition {
return key == value->GetDIEType(); return key == value->GetDIEType();
} }
HashTableLink<DwarfType>* GetLink(DwarfType* value) const DwarfType*& GetLink(DwarfType* value) const
{ {
return value; return value->fNext;
} }
}; };
@@ -72,7 +72,7 @@ private:
struct DwarfArrayType; struct DwarfArrayType;
struct DwarfTypeHashDefinition; struct DwarfTypeHashDefinition;
typedef OpenHashTable<DwarfTypeHashDefinition> TypeTable; typedef BOpenHashTable<DwarfTypeHashDefinition> TypeTable;
private: private:
status_t _CreateType(DIEType* typeEntry, status_t _CreateType(DIEType* typeEntry,
+5 -1
View File
@@ -14,7 +14,7 @@
class FileSourceCode; class FileSourceCode;
class Function : public Referenceable, public HashTableLink<Function> { class Function : public Referenceable {
public: public:
class Listener; class Listener;
@@ -69,6 +69,10 @@ private:
function_source_state fSourceCodeState; function_source_state fSourceCodeState;
ListenerList fListeners; ListenerList fListeners;
int32 fNotificationsDisabled; int32 fNotificationsDisabled;
public:
// BOpenHashTable support
Function* fNext;
}; };
@@ -72,9 +72,9 @@ struct TeamDebugInfo::FunctionHashDefinition {
&& key->Name() == value->Name(); && key->Name() == value->Name();
} }
HashTableLink<Function>* GetLink(Function* value) const Function*& GetLink(Function* value) const
{ {
return value; return value->fNext;
} }
}; };
@@ -82,7 +82,7 @@ struct TeamDebugInfo::FunctionHashDefinition {
// #pragma mark - SourceFileEntry // #pragma mark - SourceFileEntry
struct TeamDebugInfo::SourceFileEntry : public HashTableLink<SourceFileEntry> { struct TeamDebugInfo::SourceFileEntry {
SourceFileEntry(LocatableFile* sourceFile) SourceFileEntry(LocatableFile* sourceFile)
: :
fSourceFile(sourceFile), fSourceFile(sourceFile),
@@ -210,6 +210,9 @@ private:
LocatableFile* fSourceFile; LocatableFile* fSourceFile;
FileSourceCode* fSourceCode; FileSourceCode* fSourceCode;
FunctionList fFunctions; FunctionList fFunctions;
public:
SourceFileEntry* fNext;
}; };
@@ -235,9 +238,9 @@ struct TeamDebugInfo::SourceFileHashDefinition {
return key == value->SourceFile(); return key == value->SourceFile();
} }
HashTableLink<SourceFileEntry>* GetLink(SourceFileEntry* value) const SourceFileEntry*& GetLink(SourceFileEntry* value) const
{ {
return value; return value->fNext;
} }
}; };
+2 -2
View File
@@ -71,8 +71,8 @@ private:
typedef BObjectList<SpecificTeamDebugInfo> SpecificInfoList; typedef BObjectList<SpecificTeamDebugInfo> SpecificInfoList;
typedef BObjectList<ImageDebugInfo> ImageList; typedef BObjectList<ImageDebugInfo> ImageList;
typedef OpenHashTable<FunctionHashDefinition> FunctionTable; typedef BOpenHashTable<FunctionHashDefinition> FunctionTable;
typedef OpenHashTable<SourceFileHashDefinition> SourceFileTable; typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
private: private:
status_t _AddFunction(Function* function); status_t _AddFunction(Function* function);
+5 -5
View File
@@ -12,10 +12,11 @@
#include "Dwarf.h" #include "Dwarf.h"
struct AbbreviationTableEntry : HashTableLink<AbbreviationTableEntry> { struct AbbreviationTableEntry {
uint32 code; uint32 code;
off_t offset; off_t offset;
off_t size; off_t size;
AbbreviationTableEntry* next;
AbbreviationTableEntry(uint32 code, off_t offset, off_t size) AbbreviationTableEntry(uint32 code, off_t offset, off_t size)
: :
@@ -88,10 +89,9 @@ struct AbbreviationTableHashDefinition {
return value->code == key; return value->code == key;
} }
HashTableLink<AbbreviationTableEntry>* GetLink( AbbreviationTableEntry*& GetLink(AbbreviationTableEntry* value) const
AbbreviationTableEntry* value) const
{ {
return value; return value->next;
} }
}; };
@@ -109,7 +109,7 @@ public:
AbbreviationEntry& entry); AbbreviationEntry& entry);
private: private:
typedef OpenHashTable<AbbreviationTableHashDefinition> EntryTable; typedef BOpenHashTable<AbbreviationTableHashDefinition> EntryTable;
private: private:
status_t _ParseAbbreviationEntry( status_t _ParseAbbreviationEntry(
+6 -6
View File
@@ -92,9 +92,9 @@ struct FileManager::EntryHashDefinition {
return EntryPath(value) == key; return EntryPath(value) == key;
} }
HashTableLink<LocatableEntry>* GetLink(LocatableEntry* value) const LocatableEntry*& GetLink(LocatableEntry* value) const
{ {
return value; return value->fNext;
} }
}; };
@@ -459,12 +459,12 @@ private:
// #pragma mark - SourceFileEntry // #pragma mark - SourceFileEntry
struct FileManager::SourceFileEntry : public SourceFileOwner, struct FileManager::SourceFileEntry : public SourceFileOwner {
public HashTableLink<SourceFileEntry> {
FileManager* manager; FileManager* manager;
BString path; BString path;
SourceFile* file; SourceFile* file;
SourceFileEntry* next;
SourceFileEntry(FileManager* manager, const BString& path) SourceFileEntry(FileManager* manager, const BString& path)
: :
@@ -509,9 +509,9 @@ struct FileManager::SourceFileHashDefinition {
return value->path == key; return value->path == key;
} }
HashTableLink<SourceFileEntry>* GetLink(SourceFileEntry* value) const SourceFileEntry*& GetLink(SourceFileEntry* value) const
{ {
return value; return value->next;
} }
}; };
+2 -2
View File
@@ -52,8 +52,8 @@ private:
struct SourceFileEntry; struct SourceFileEntry;
struct SourceFileHashDefinition; struct SourceFileHashDefinition;
typedef OpenHashTable<EntryHashDefinition> LocatableEntryTable; typedef BOpenHashTable<EntryHashDefinition> LocatableEntryTable;
typedef OpenHashTable<SourceFileHashDefinition> SourceFileTable; typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
friend struct SourceFileEntry; friend struct SourceFileEntry;
// for gcc 2 // for gcc 2
+4 -2
View File
@@ -35,8 +35,7 @@ public:
class LocatableEntry : public Referenceable, class LocatableEntry : public Referenceable,
public DoublyLinkedListLinkImpl<LocatableEntry>, public DoublyLinkedListLinkImpl<LocatableEntry> {
public HashTableLink<LocatableEntry> {
public: public:
LocatableEntry(LocatableEntryOwner* owner, LocatableEntry(LocatableEntryOwner* owner,
LocatableDirectory* parent); LocatableDirectory* parent);
@@ -58,6 +57,9 @@ protected:
LocatableEntryOwner* fOwner; LocatableEntryOwner* fOwner;
LocatableDirectory* fParent; LocatableDirectory* fParent;
locatable_entry_state fState; locatable_entry_state fState;
public:
LocatableEntry* fNext;
}; };
+5 -4
View File
@@ -35,8 +35,9 @@ struct StackFrameValues::Key {
}; };
struct StackFrameValues::ValueEntry : Key, HashTableLink<ValueEntry> { struct StackFrameValues::ValueEntry : Key {
BVariant value; BVariant value;
ValueEntry* next;
ValueEntry(ObjectID* variable, TypeComponentPath* path) ValueEntry(ObjectID* variable, TypeComponentPath* path)
: :
@@ -73,9 +74,9 @@ struct StackFrameValues::ValueEntryHashDefinition {
return key == *value; return key == *value;
} }
HashTableLink<ValueEntry>* GetLink(ValueEntry* value) const ValueEntry*& GetLink(ValueEntry* value) const
{ {
return value; return value->next;
} }
}; };
@@ -172,7 +173,7 @@ StackFrameValues::_Cleanup()
ValueEntry* entry = fValues->Clear(true); ValueEntry* entry = fValues->Clear(true);
while (entry != NULL) { while (entry != NULL) {
ValueEntry* next = entry->fNext; ValueEntry* next = entry->next;
delete entry; delete entry;
entry = next; entry = next;
} }
+1 -1
View File
@@ -43,7 +43,7 @@ private:
struct ValueEntry; struct ValueEntry;
struct ValueEntryHashDefinition; struct ValueEntryHashDefinition;
typedef OpenHashTable<ValueEntryHashDefinition> ValueTable; typedef BOpenHashTable<ValueEntryHashDefinition> ValueTable;
private: private:
StackFrameValues& operator=(const StackFrameValues& other); StackFrameValues& operator=(const StackFrameValues& other);
+6 -4
View File
@@ -32,6 +32,8 @@
#include <agg_array.h> #include <agg_array.h>
#include <util/OpenHashTable.h>
#include <Autolock.h> #include <Autolock.h>
#include "utf8_functions.h" #include "utf8_functions.h"
@@ -52,7 +54,7 @@ public:
{ {
GlyphCache* glyph = fGlyphTable.Clear(true); GlyphCache* glyph = fGlyphTable.Clear(true);
while (glyph != NULL) { while (glyph != NULL) {
GlyphCache* next = glyph->fNext; GlyphCache* next = glyph->hash_link;
delete glyph; delete glyph;
glyph = next; glyph = next;
} }
@@ -111,13 +113,13 @@ private:
return value->glyph_index == key; return value->glyph_index == key;
} }
HashTableLink<GlyphCache>* GetLink(GlyphCache* value) const GlyphCache*& GetLink(GlyphCache* value) const
{ {
return value; return value->hash_link;
} }
}; };
typedef OpenHashTable<GlyphHashTableDefinition> GlyphTable; typedef BOpenHashTable<GlyphHashTableDefinition> GlyphTable;
GlyphTable fGlyphTable; GlyphTable fGlyphTable;
}; };
+3 -3
View File
@@ -33,8 +33,6 @@
#include <agg_conv_contour.h> #include <agg_conv_contour.h>
#include <agg_conv_transform.h> #include <agg_conv_transform.h>
#include <util/OpenHashTable.h>
#include "ServerFont.h" #include "ServerFont.h"
#include "FontEngine.h" #include "FontEngine.h"
#include "MultiLocker.h" #include "MultiLocker.h"
@@ -42,7 +40,7 @@
#include "Transformable.h" #include "Transformable.h"
struct GlyphCache : public HashTableLink<GlyphCache> { struct GlyphCache {
GlyphCache(uint32 glyphIndex, uint32 dataSize, glyph_data_type dataType, GlyphCache(uint32 glyphIndex, uint32 dataSize, glyph_data_type dataType,
const agg::rect_i& bounds, float advanceX, float advanceY, const agg::rect_i& bounds, float advanceX, float advanceY,
float insetLeft, float insetRight) float insetLeft, float insetRight)
@@ -73,6 +71,8 @@ struct GlyphCache : public HashTableLink<GlyphCache> {
float advance_y; float advance_y;
float inset_left; float inset_left;
float inset_right; float inset_right;
GlyphCache* hash_link;
}; };
class FontCache; class FontCache;
+3 -3
View File
@@ -36,11 +36,11 @@ struct ConditionVariableHashDefinition {
{ return (size_t)variable->fObject; } { return (size_t)variable->fObject; }
bool Compare(const void* key, ConditionVariable* variable) const bool Compare(const void* key, ConditionVariable* variable) const
{ return key == variable->fObject; } { return key == variable->fObject; }
HashTableLink<ConditionVariable>* GetLink(ConditionVariable* variable) const ConditionVariable*& GetLink(ConditionVariable* variable) const
{ return variable; } { return variable->fNext; }
}; };
typedef OpenHashTable<ConditionVariableHashDefinition> ConditionVariableHash; typedef BOpenHashTable<ConditionVariableHashDefinition> ConditionVariableHash;
static ConditionVariableHash sConditionVariableHash; static ConditionVariableHash sConditionVariableHash;
static spinlock sConditionVariablesLock; static spinlock sConditionVariablesLock;
+5 -4
View File
@@ -126,7 +126,8 @@ private:
}; };
struct WaitObject : DoublyLinkedListLinkImpl<WaitObject>, struct WaitObject : DoublyLinkedListLinkImpl<WaitObject>,
HashTableLink<WaitObject>, WaitObjectKey { WaitObjectKey {
struct WaitObject* hash_link;
}; };
struct WaitObjectTableDefinition { struct WaitObjectTableDefinition {
@@ -150,14 +151,14 @@ private:
&& value->object == key.object; && value->object == key.object;
} }
HashTableLink<WaitObject>* GetLink(WaitObject* value) const WaitObject*& GetLink(WaitObject* value) const
{ {
return value; return value->hash_link;
} }
}; };
typedef DoublyLinkedList<WaitObject> WaitObjectList; typedef DoublyLinkedList<WaitObject> WaitObjectList;
typedef OpenHashTable<WaitObjectTableDefinition> WaitObjectTable; typedef BOpenHashTable<WaitObjectTableDefinition> WaitObjectTable;
private: private:
spinlock fLock; spinlock fLock;
@@ -87,12 +87,12 @@ struct IOScheduler::RequestOwnerHashDefinition {
size_t Hash(const IORequestOwner* value) const { return value->thread; } size_t Hash(const IORequestOwner* value) const { return value->thread; }
bool Compare(thread_id key, const IORequestOwner* value) const bool Compare(thread_id key, const IORequestOwner* value) const
{ return value->thread == key; } { return value->thread == key; }
HashTableLink<IORequestOwner>* GetLink(IORequestOwner* value) const IORequestOwner*& GetLink(IORequestOwner* value) const
{ return value; } { return value->hash_link; }
}; };
struct IOScheduler::RequestOwnerHashTable struct IOScheduler::RequestOwnerHashTable
: OpenHashTable<RequestOwnerHashDefinition, false> { : BOpenHashTable<RequestOwnerHashDefinition, false> {
}; };
@@ -27,14 +27,14 @@ public:
typedef status_t (*io_callback)(void* data, io_operation* operation); typedef status_t (*io_callback)(void* data, io_operation* operation);
struct IORequestOwner : DoublyLinkedListLinkImpl<IORequestOwner>, struct IORequestOwner : DoublyLinkedListLinkImpl<IORequestOwner> {
HashTableLink<IORequestOwner> {
team_id team; team_id team;
thread_id thread; thread_id thread;
int32 priority; int32 priority;
IORequestList requests; IORequestList requests;
IORequestList completed_requests; IORequestList completed_requests;
IOOperationList operations; IOOperationList operations;
IORequestOwner* hash_link;
bool IsActive() const bool IsActive() const
{ return !requests.IsEmpty() { return !requests.IsEmpty()
@@ -120,7 +120,7 @@ struct driver_entry : public DoublyLinkedListLinkImpl<driver_entry> {
typedef DoublyLinkedList<driver_entry> DriverEntryList; typedef DoublyLinkedList<driver_entry> DriverEntryList;
struct directory_node_entry { struct directory_node_entry {
HashTableLink<directory_node_entry> link; directory_node_entry* hash_link;
ino_t node; ino_t node;
}; };
@@ -134,15 +134,15 @@ struct DirectoryNodeHashDefinition {
{ return _Hash(entry->node); } { return _Hash(entry->node); }
bool Compare(ino_t* key, directory_node_entry* entry) const bool Compare(ino_t* key, directory_node_entry* entry) const
{ return *key == entry->node; } { return *key == entry->node; }
HashTableLink<directory_node_entry>* directory_node_entry*&
GetLink(directory_node_entry* entry) const GetLink(directory_node_entry* entry) const
{ return &entry->link; } { return entry->hash_link; }
uint32 _Hash(ino_t node) const uint32 _Hash(ino_t node) const
{ return (uint32)(node >> 32) + (uint32)node; } { return (uint32)(node >> 32) + (uint32)node; }
}; };
typedef OpenHashTable<DirectoryNodeHashDefinition> DirectoryNodeHash; typedef BOpenHashTable<DirectoryNodeHashDefinition> DirectoryNodeHash;
class DirectoryIterator { class DirectoryIterator {
public: public:
+4 -5
View File
@@ -54,7 +54,7 @@ typedef DoublyLinkedList<monitor_listener, DoublyLinkedListMemberGetLink<
monitor_listener, &monitor_listener::monitor_link> > MonitorListenerList; monitor_listener, &monitor_listener::monitor_link> > MonitorListenerList;
struct node_monitor { struct node_monitor {
HashTableLink<node_monitor> link; node_monitor* hash_link;
dev_t device; dev_t device;
ino_t node; ino_t node;
MonitorListenerList listeners; MonitorListenerList listeners;
@@ -164,9 +164,8 @@ class NodeMonitorService : public NotificationService {
&& key->node == monitor->node; && key->node == monitor->node;
} }
HashTableLink<node_monitor>* GetLink( node_monitor*& GetLink(node_monitor* monitor) const
node_monitor* monitor) const { return monitor->hash_link; }
{ return &monitor->link; }
uint32 _Hash(dev_t device, ino_t node) const uint32 _Hash(dev_t device, ino_t node) const
{ {
@@ -174,7 +173,7 @@ class NodeMonitorService : public NotificationService {
} }
}; };
typedef OpenHashTable<HashDefinition> MonitorHash; typedef BOpenHashTable<HashDefinition> MonitorHash;
MonitorHash fMonitors; MonitorHash fMonitors;
recursive_lock fRecursiveLock; recursive_lock fRecursiveLock;
}; };
+5 -5
View File
@@ -123,8 +123,8 @@ struct EntryCacheKey {
}; };
struct EntryCacheEntry : HashTableLink<EntryCacheEntry>, struct EntryCacheEntry : DoublyLinkedListLinkImpl<EntryCacheEntry> {
DoublyLinkedListLinkImpl<EntryCacheEntry> { EntryCacheEntry* hash_link;
ino_t node_id; ino_t node_id;
ino_t dir_id; ino_t dir_id;
char name[1]; char name[1];
@@ -153,9 +153,9 @@ struct EntryCacheHashDefinition {
&& strcmp(value->name, key.name) == 0; && strcmp(value->name, key.name) == 0;
} }
HashTableLink<EntryCacheEntry>* GetLink(EntryCacheEntry* value) const EntryCacheEntry*& GetLink(EntryCacheEntry* value) const
{ {
return value; return value->hash_link;
} }
}; };
@@ -251,7 +251,7 @@ public:
} }
private: private:
typedef OpenHashTable<EntryCacheHashDefinition> EntryTable; typedef BOpenHashTable<EntryCacheHashDefinition> EntryTable;
typedef DoublyLinkedList<EntryCacheEntry> EntryList; typedef DoublyLinkedList<EntryCacheEntry> EntryList;
mutex fLock; mutex fLock;
+3 -3
View File
@@ -41,11 +41,11 @@ struct ImageTableDefinition {
size_t Hash(struct image* value) const { return value->info.id; } size_t Hash(struct image* value) const { return value->info.id; }
bool Compare(image_id key, struct image* value) const bool Compare(image_id key, struct image* value) const
{ return value->info.id == key; } { return value->info.id == key; }
HashTableLink<struct image>* GetLink(struct image* value) const struct image*& GetLink(struct image* value) const
{ return &value->hash_link; } { return value->hash_link; }
}; };
typedef OpenHashTable<ImageTableDefinition> ImageTable; typedef BOpenHashTable<ImageTableDefinition> ImageTable;
class ImageNotificationService : public DefaultNotificationService { class ImageNotificationService : public DefaultNotificationService {
+4 -4
View File
@@ -154,7 +154,7 @@ struct hash_entry : entry {
free((char*)path); free((char*)path);
} }
HashTableLink<hash_entry> link; hash_entry* hash_link;
const char* path; const char* path;
}; };
@@ -164,8 +164,8 @@ struct NodeHashDefinition {
size_t Hash(ValueType* entry) const size_t Hash(ValueType* entry) const
{ return HashKey(entry); } { return HashKey(entry); }
HashTableLink<ValueType>* GetLink(ValueType* entry) const ValueType*& GetLink(ValueType* entry) const
{ return &entry->link; } { return entry->hash_link; }
size_t HashKey(KeyType key) const size_t HashKey(KeyType key) const
{ {
@@ -179,7 +179,7 @@ struct NodeHashDefinition {
} }
}; };
typedef OpenHashTable<NodeHashDefinition> NodeHash; typedef BOpenHashTable<NodeHashDefinition> NodeHash;
struct module_listener : DoublyLinkedListLinkImpl<module_listener> { struct module_listener : DoublyLinkedListLinkImpl<module_listener> {
~module_listener() ~module_listener()
+15 -15
View File
@@ -134,9 +134,9 @@ public:
ReleaseReference(); ReleaseReference();
} }
HashTableLink<NamedSem>* HashLink() NamedSem*& HashLink()
{ {
return &fHashLink; return fHashLink;
} }
private: private:
@@ -146,7 +146,7 @@ private:
gid_t fGID; gid_t fGID;
mode_t fPermissions; mode_t fPermissions;
::HashTableLink<NamedSem> fHashLink; NamedSem* fHashLink;
}; };
@@ -238,13 +238,13 @@ public:
delete this; delete this;
} }
HashTableLink<UnnamedSharedSem>* HashLink() UnnamedSharedSem*& HashLink()
{ {
return &fHashLink; return fHashLink;
} }
private: private:
::HashTableLink<UnnamedSharedSem> fHashLink; UnnamedSharedSem* fHashLink;
}; };
@@ -267,7 +267,7 @@ struct NamedSemHashDefinition {
return strcmp(key, semaphore->Name()) == 0; return strcmp(key, semaphore->Name()) == 0;
} }
HashTableLink<NamedSem>* GetLink(NamedSem* semaphore) const NamedSem*& GetLink(NamedSem* semaphore) const
{ {
return semaphore->HashLink(); return semaphore->HashLink();
} }
@@ -293,7 +293,7 @@ struct UnnamedSemHashDefinition {
return key == semaphore->SemaphoreID(); return key == semaphore->SemaphoreID();
} }
HashTableLink<UnnamedSharedSem>* GetLink(UnnamedSharedSem* semaphore) const UnnamedSharedSem*& GetLink(UnnamedSharedSem* semaphore) const
{ {
return semaphore->HashLink(); return semaphore->HashLink();
} }
@@ -442,8 +442,8 @@ public:
} }
private: private:
typedef OpenHashTable<NamedSemHashDefinition, true> NamedSemTable; typedef BOpenHashTable<NamedSemHashDefinition, true> NamedSemTable;
typedef OpenHashTable<UnnamedSemHashDefinition, true> UnnamedSemTable; typedef BOpenHashTable<UnnamedSemHashDefinition, true> UnnamedSemTable;
mutex fLock; mutex fLock;
NamedSemTable fNamedSemaphores; NamedSemTable fNamedSemaphores;
@@ -502,9 +502,9 @@ public:
return clone; return clone;
} }
HashTableLink<TeamSemInfo>* HashLink() TeamSemInfo*& HashLink()
{ {
return &fHashLink; return fHashLink;
} }
private: private:
@@ -512,7 +512,7 @@ private:
sem_t* fUserSemaphore; sem_t* fUserSemaphore;
int32 fOpenCount; int32 fOpenCount;
::HashTableLink<TeamSemInfo> fHashLink; TeamSemInfo* fHashLink;
}; };
@@ -535,7 +535,7 @@ struct TeamSemHashDefinition {
return key == semaphore->ID(); return key == semaphore->ID();
} }
HashTableLink<TeamSemInfo>* GetLink(TeamSemInfo* semaphore) const TeamSemInfo*& GetLink(TeamSemInfo* semaphore) const
{ {
return semaphore->HashLink(); return semaphore->HashLink();
} }
@@ -799,7 +799,7 @@ private:
} }
private: private:
typedef OpenHashTable<TeamSemHashDefinition, true> SemTable; typedef BOpenHashTable<TeamSemHashDefinition, true> SemTable;
mutex fLock; mutex fLock;
SemTable fSemaphores; SemTable fSemaphores;
+10 -10
View File
@@ -266,9 +266,9 @@ public:
} }
} }
HashTableLink<XsiMessageQueue>* Link() XsiMessageQueue*& Link()
{ {
return &fLink; return fLink;
} }
private: private:
@@ -284,7 +284,7 @@ private:
ThreadQueue fWaitingToReceive; ThreadQueue fWaitingToReceive;
ThreadQueue fWaitingToSend; ThreadQueue fWaitingToSend;
::HashTableLink<XsiMessageQueue> fLink; XsiMessageQueue* fLink;
}; };
@@ -308,7 +308,7 @@ struct MessageQueueHashTableDefinition {
return (int)key == (int)variable->ID(); return (int)key == (int)variable->ID();
} }
HashTableLink<XsiMessageQueue>* GetLink(XsiMessageQueue *variable) const XsiMessageQueue*& GetLink(XsiMessageQueue *variable) const
{ {
return variable->Link(); return variable->Link();
} }
@@ -339,15 +339,15 @@ public:
fMessageQueueId = messageQueue->ID(); fMessageQueueId = messageQueue->ID();
} }
HashTableLink<Ipc>* Link() Ipc*& Link()
{ {
return &fLink; return fLink;
} }
private: private:
key_t fKey; key_t fKey;
int fMessageQueueId; int fMessageQueueId;
HashTableLink<Ipc> fLink; Ipc* fLink;
}; };
@@ -370,7 +370,7 @@ struct IpcHashTableDefinition {
return (key_t)key == (key_t)variable->Key(); return (key_t)key == (key_t)variable->Key();
} }
HashTableLink<Ipc>* GetLink(Ipc *variable) const Ipc*& GetLink(Ipc *variable) const
{ {
return variable->Link(); return variable->Link();
} }
@@ -379,8 +379,8 @@ struct IpcHashTableDefinition {
// Arbitrary limits // Arbitrary limits
#define MAX_XSI_MESSAGE 4096 #define MAX_XSI_MESSAGE 4096
#define MAX_XSI_MESSAGE_QUEUE 1024 #define MAX_XSI_MESSAGE_QUEUE 1024
static OpenHashTable<IpcHashTableDefinition> sIpcHashTable; static BOpenHashTable<IpcHashTableDefinition> sIpcHashTable;
static OpenHashTable<MessageQueueHashTableDefinition> sMessageQueueHashTable; static BOpenHashTable<MessageQueueHashTableDefinition> sMessageQueueHashTable;
static mutex sIpcLock; static mutex sIpcLock;
static mutex sXsiMessageQueueLock; static mutex sXsiMessageQueueLock;
+10 -10
View File
@@ -515,9 +515,9 @@ public:
return fUndoList; return fUndoList;
} }
HashTableLink<XsiSemaphoreSet>* Link() XsiSemaphoreSet*& Link()
{ {
return &fLink; return fLink;
} }
private: private:
@@ -532,7 +532,7 @@ private:
uint32 fSequenceNumber; // used as a second id uint32 fSequenceNumber; // used as a second id
UndoList fUndoList; // undo list requests UndoList fUndoList; // undo list requests
::HashTableLink<XsiSemaphoreSet> fLink; XsiSemaphoreSet* fLink;
}; };
// Xsi semaphore set hash table // Xsi semaphore set hash table
@@ -555,7 +555,7 @@ struct SemaphoreHashTableDefinition {
return (int)key == (int)variable->ID(); return (int)key == (int)variable->ID();
} }
HashTableLink<XsiSemaphoreSet>* GetLink(XsiSemaphoreSet *variable) const XsiSemaphoreSet*& GetLink(XsiSemaphoreSet *variable) const
{ {
return variable->Link(); return variable->Link();
} }
@@ -586,15 +586,15 @@ public:
fSemaphoreSetId = semaphoreSet->ID(); fSemaphoreSetId = semaphoreSet->ID();
} }
HashTableLink<Ipc>* Link() Ipc*& Link()
{ {
return &fLink; return fLink;
} }
private: private:
key_t fKey; key_t fKey;
int fSemaphoreSetId; int fSemaphoreSetId;
HashTableLink<Ipc> fLink; Ipc* fLink;
}; };
@@ -617,7 +617,7 @@ struct IpcHashTableDefinition {
return (key_t)key == (key_t)variable->Key(); return (key_t)key == (key_t)variable->Key();
} }
HashTableLink<Ipc>* GetLink(Ipc *variable) const Ipc*& GetLink(Ipc *variable) const
{ {
return variable->Link(); return variable->Link();
} }
@@ -626,8 +626,8 @@ struct IpcHashTableDefinition {
// Arbitrary limit // Arbitrary limit
#define MAX_XSI_SEMAPHORE 4096 #define MAX_XSI_SEMAPHORE 4096
#define MAX_XSI_SEMAPHORE_SET 2048 #define MAX_XSI_SEMAPHORE_SET 2048
static OpenHashTable<IpcHashTableDefinition> sIpcHashTable; static BOpenHashTable<IpcHashTableDefinition> sIpcHashTable;
static OpenHashTable<SemaphoreHashTableDefinition> sSemaphoreHashTable; static BOpenHashTable<SemaphoreHashTableDefinition> sSemaphoreHashTable;
static mutex sIpcLock; static mutex sIpcLock;
static mutex sXsiSemaphoreSetLock; static mutex sXsiSemaphoreSetLock;
+4 -3
View File
@@ -122,9 +122,10 @@ struct SmallObjectCache : object_cache {
struct HashedObjectCache : object_cache { struct HashedObjectCache : object_cache {
struct Link : HashTableLink<Link> { struct Link {
const void* buffer; const void* buffer;
slab* parent; slab* parent;
Link* next;
}; };
struct Definition { struct Definition {
@@ -144,12 +145,12 @@ struct HashedObjectCache : object_cache {
size_t Hash(Link *value) const { return HashKey(value->buffer); } size_t Hash(Link *value) const { return HashKey(value->buffer); }
bool Compare(const void *key, Link *value) const bool Compare(const void *key, Link *value) const
{ return value->buffer == key; } { return value->buffer == key; }
HashTableLink<Link> *GetLink(Link *value) const { return value; } Link*& GetLink(Link *value) const { return value->next; }
HashedObjectCache *parent; HashedObjectCache *parent;
}; };
typedef OpenHashTable<Definition> HashTable; typedef BOpenHashTable<Definition> HashTable;
HashedObjectCache() HashedObjectCache()
: hash_table(this) {} : hash_table(this) {}
+5 -4
View File
@@ -80,7 +80,8 @@ struct swap_hash_key {
// Each swap block contains swap address information for // Each swap block contains swap address information for
// SWAP_BLOCK_PAGES continuous pages from the same cache // SWAP_BLOCK_PAGES continuous pages from the same cache
struct swap_block : HashTableLink<swap_block> { struct swap_block {
swap_block* hash_link;
swap_hash_key key; swap_hash_key key;
uint32 used; uint32 used;
swap_addr_t swap_slots[SWAP_BLOCK_PAGES]; swap_addr_t swap_slots[SWAP_BLOCK_PAGES];
@@ -111,13 +112,13 @@ struct SwapHashTableDefinition {
&& key.cache == value->key.cache; && key.cache == value->key.cache;
} }
HashTableLink<swap_block> *GetLink(swap_block *value) const swap_block*& GetLink(swap_block *value) const
{ {
return value; return value->hash_link;
} }
}; };
typedef OpenHashTable<SwapHashTableDefinition> SwapHashTable; typedef BOpenHashTable<SwapHashTableDefinition> SwapHashTable;
typedef DoublyLinkedList<swap_file> SwapFileList; typedef DoublyLinkedList<swap_file> SwapFileList;
static SwapHashTable sSwapHashTable; static SwapHashTable sSwapHashTable;
@@ -41,11 +41,11 @@ struct ConditionVariableHashDefinition {
{ return (size_t)variable->fObject; } { return (size_t)variable->fObject; }
bool Compare(const void* key, ConditionVariable* variable) const bool Compare(const void* key, ConditionVariable* variable) const
{ return key == variable->fObject; } { return key == variable->fObject; }
HashTableLink<ConditionVariable>* GetLink(ConditionVariable* variable) const ConditionVariable*& GetLink(ConditionVariable* variable) const
{ return variable; } { return variable->fNext; }
}; };
typedef OpenHashTable<ConditionVariableHashDefinition> ConditionVariableHash; typedef BOpenHashTable<ConditionVariableHashDefinition> ConditionVariableHash;
static ConditionVariableHash sConditionVariableHash; static ConditionVariableHash sConditionVariableHash;
static mutex sConditionVariablesLock = MUTEX_INITIALIZER("condition variables"); static mutex sConditionVariablesLock = MUTEX_INITIALIZER("condition variables");