Bug 849654: Kill nsClassHashtableMT. r=bsmedberg

This commit is contained in:
Kyle Huey 2013-03-12 13:33:40 -07:00
Родитель 594c29e504
Коммит c969fba3bb
2 изменённых файлов: 0 добавлений и 117 удалений

Просмотреть файл

@ -52,31 +52,6 @@ public:
void RemoveAndForget(KeyType aKey, nsAutoPtr<T> &aOut);
};
/**
* Thread-safe version of nsClassHashtable
* @param KeyClass a wrapper-class for the hashtable key, see nsHashKeys.h
* for a complete specification.
* @param Class the class-type being wrapped
* @see nsInterfaceHashtable, nsClassHashtable
*/
template<class KeyClass,class T>
class nsClassHashtableMT :
public nsBaseHashtableMT< KeyClass, nsAutoPtr<T>, T* >
{
public:
typedef typename KeyClass::KeyType KeyType;
typedef T* UserDataType;
typedef nsBaseHashtableMT< KeyClass, nsAutoPtr<T>, T* > base_type;
/**
* @copydoc nsBaseHashtable::Get
* @param pData if the key doesn't exist, pData will be set to nullptr.
*/
bool Get(KeyType aKey, UserDataType* pData) const;
};
//
// nsClassHashtable definitions
//
@ -130,35 +105,4 @@ nsClassHashtable<KeyClass,T>::RemoveAndForget(KeyType aKey, nsAutoPtr<T> &aOut)
this->Remove(aKey);
}
//
// nsClassHashtableMT definitions
//
template<class KeyClass,class T>
bool
nsClassHashtableMT<KeyClass,T>::Get(KeyType aKey, T** retVal) const
{
PR_Lock(this->mLock);
typename base_type::EntryType* ent = this->GetEntry(aKey);
if (ent)
{
if (retVal)
*retVal = ent->mData;
PR_Unlock(this->mLock);
return true;
}
if (retVal)
*retVal = nullptr;
PR_Unlock(this->mLock);
return false;
}
#endif // nsClassHashtable_h__

Просмотреть файл

@ -595,67 +595,6 @@ main(void) {
printf("OK\n");
//
// now check a thread-safe class-hashtable
//
nsClassHashtableMT<nsCStringHashKey,TestUniChar> EntToUniClassL;
printf("Initializing nsClassHashtableMT...");
EntToUniClassL.Init(ENTITY_COUNT);
printf("OK\n");
printf("Filling hash with %u entries.\n", ENTITY_COUNT);
for (i = 0; i < ENTITY_COUNT; ++i) {
printf(" Putting entry %u...", gEntities[i].mUnicode);
TestUniChar* temp = new TestUniChar(gEntities[i].mUnicode);
EntToUniClassL.Put(nsDependentCString(gEntities[i].mStr), temp);
printf("OK...\n");
}
printf("Testing Get:\n");
for (i = 0; i < ENTITY_COUNT; ++i) {
printf(" Getting entry %s...", gEntities[i].mStr);
if (!EntToUniClassL.Get(nsDependentCString(gEntities[i].mStr), &myChar)) {
printf("FAILED\n");
exit (18);
}
printf("Found %c\n", myChar->GetChar());
}
printf("Testing nonexistent entries...");
if (EntToUniClassL.Get(NS_LITERAL_CSTRING("xxxx"), &myChar)) {
printf("FOUND! BAD!\n");
exit (19);
}
printf("not found; good.\n");
printf("Enumerating:\n");
count = EntToUniClassL.EnumerateRead(nsCEnumRead, nullptr);
if (count != ENTITY_COUNT) {
printf(" Bad count!\n");
exit (20);
}
printf("Clearing...\n");
EntToUniClassL.Clear();
printf(" Clearing OK\n");
printf("Checking count...");
count = EntToUniClassL.Enumerate(nsCEnum, nullptr);
if (count) {
printf(" Clear did not remove all entries.\n");
exit (21);
}
printf("OK\n");
//
// now check a data-hashtable with an interface key
//