|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* Implementation of xptiWorkingSet. */ |
|
7 |
|
8 #include "mozilla/XPTInterfaceInfoManager.h" |
|
9 |
|
10 #include "xptiprivate.h" |
|
11 #include "nsString.h" |
|
12 |
|
13 using namespace mozilla; |
|
14 |
|
15 #define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16) |
|
16 #define XPTI_HASHTABLE_SIZE 2048 |
|
17 |
|
18 XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet() |
|
19 : mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor") |
|
20 , mIIDTable(XPTI_HASHTABLE_SIZE) |
|
21 , mNameTable(XPTI_HASHTABLE_SIZE) |
|
22 { |
|
23 MOZ_COUNT_CTOR(xptiWorkingSet); |
|
24 |
|
25 gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double), |
|
26 "xptiWorkingSet structs"); |
|
27 } |
|
28 |
|
29 static PLDHashOperator |
|
30 xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg) |
|
31 { |
|
32 entry->LockedInvalidateInterfaceInfo(); |
|
33 return PL_DHASH_NEXT; |
|
34 } |
|
35 |
|
36 void |
|
37 XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos() |
|
38 { |
|
39 ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor); |
|
40 mNameTable.EnumerateRead(xpti_Invalidator, nullptr); |
|
41 } |
|
42 |
|
43 XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet() |
|
44 { |
|
45 MOZ_COUNT_DTOR(xptiWorkingSet); |
|
46 |
|
47 // Only destroy the arena if we're doing leak stats. Why waste shutdown |
|
48 // time touching pages if we don't have to? |
|
49 #ifdef NS_FREE_PERMANENT_DATA |
|
50 XPT_DestroyArena(gXPTIStructArena); |
|
51 #endif |
|
52 } |
|
53 |
|
54 XPTArena* gXPTIStructArena; |