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