2000-03-28 09:10:05 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2000-03-28 09:10:05 +04:00
|
|
|
|
|
|
|
/* Implementation of xptiWorkingSet. */
|
|
|
|
|
2013-03-09 06:54:10 +04:00
|
|
|
#include "mozilla/XPTInterfaceInfoManager.h"
|
|
|
|
|
2000-03-28 09:10:05 +04:00
|
|
|
#include "xptiprivate.h"
|
2002-04-27 09:33:09 +04:00
|
|
|
#include "nsString.h"
|
2000-03-28 09:10:05 +04:00
|
|
|
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-11-13 04:14:04 +04:00
|
|
|
#define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16)
|
2014-08-06 17:31:21 +04:00
|
|
|
#define XPTI_HASHTABLE_LENGTH 1024
|
2000-03-28 09:10:05 +04:00
|
|
|
|
2013-03-09 06:54:10 +04:00
|
|
|
XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
|
2011-04-29 23:21:57 +04:00
|
|
|
: mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
|
2014-08-06 17:31:21 +04:00
|
|
|
, mIIDTable(XPTI_HASHTABLE_LENGTH)
|
|
|
|
, mNameTable(XPTI_HASHTABLE_LENGTH)
|
2000-03-28 09:10:05 +04:00
|
|
|
{
|
2000-06-15 06:18:32 +04:00
|
|
|
MOZ_COUNT_CTOR(xptiWorkingSet);
|
2000-03-28 09:10:05 +04:00
|
|
|
|
2010-06-10 20:51:29 +04:00
|
|
|
gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
|
|
|
|
"xptiWorkingSet structs");
|
|
|
|
}
|
2000-03-28 09:10:05 +04:00
|
|
|
|
2008-10-10 19:04:34 +04:00
|
|
|
static PLDHashOperator
|
2010-06-10 20:51:29 +04:00
|
|
|
xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
|
2000-03-28 09:10:05 +04:00
|
|
|
{
|
2002-01-11 02:49:47 +03:00
|
|
|
entry->LockedInvalidateInterfaceInfo();
|
|
|
|
return PL_DHASH_NEXT;
|
2000-03-28 09:10:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-09 06:54:10 +04:00
|
|
|
XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
|
2000-03-28 09:10:05 +04:00
|
|
|
{
|
2011-04-29 23:21:57 +04:00
|
|
|
ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
|
2013-10-11 00:42:16 +04:00
|
|
|
mNameTable.EnumerateRead(xpti_Invalidator, nullptr);
|
2000-03-28 09:10:05 +04:00
|
|
|
}
|
|
|
|
|
2013-03-09 06:54:10 +04:00
|
|
|
XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
|
2000-03-28 09:10:05 +04:00
|
|
|
{
|
2000-06-15 06:18:32 +04:00
|
|
|
MOZ_COUNT_DTOR(xptiWorkingSet);
|
|
|
|
|
2010-07-14 21:09:42 +04:00
|
|
|
// 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
|
2011-06-17 20:22:15 +04:00
|
|
|
}
|
2000-03-28 09:10:05 +04:00
|
|
|
|
2010-06-10 20:51:29 +04:00
|
|
|
XPTArena* gXPTIStructArena;
|