gecko/xpcom/reflect/xptinfo/xptiWorkingSet.cpp
Nicholas Nethercote 8c60d14a1a Bug 1050009 - Initialize pldhash tables with a length, not a capacity. r=roc.
* * *
imported patch rm-dummy-params

--HG--
extra : rebase_source : c25987eb11bae197218d5fc53b77def19afa36ac
2014-08-06 06:31:21 -07:00

55 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* Implementation of xptiWorkingSet. */
#include "mozilla/XPTInterfaceInfoManager.h"
#include "xptiprivate.h"
#include "nsString.h"
using namespace mozilla;
#define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16)
#define XPTI_HASHTABLE_LENGTH 1024
XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
: mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
, mIIDTable(XPTI_HASHTABLE_LENGTH)
, mNameTable(XPTI_HASHTABLE_LENGTH)
{
MOZ_COUNT_CTOR(xptiWorkingSet);
gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
"xptiWorkingSet structs");
}
static PLDHashOperator
xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
{
entry->LockedInvalidateInterfaceInfo();
return PL_DHASH_NEXT;
}
void
XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
{
ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
mNameTable.EnumerateRead(xpti_Invalidator, nullptr);
}
XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
{
MOZ_COUNT_DTOR(xptiWorkingSet);
// Only destroy the arena if we're doing leak stats. Why waste shutdown
// time touching pages if we don't have to?
#ifdef NS_FREE_PERMANENT_DATA
XPT_DestroyArena(gXPTIStructArena);
#endif
}
XPTArena* gXPTIStructArena;