xpcom/reflect/xptinfo/src/xptiWorkingSet.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 /* Implementation of xptiWorkingSet. */
     8 #include "mozilla/XPTInterfaceInfoManager.h"
    10 #include "xptiprivate.h"
    11 #include "nsString.h"
    13 using namespace mozilla;
    15 #define XPTI_STRUCT_ARENA_BLOCK_SIZE    (1024 * 16)
    16 #define XPTI_HASHTABLE_SIZE             2048
    18 XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
    19     : mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
    20     , mIIDTable(XPTI_HASHTABLE_SIZE)
    21     , mNameTable(XPTI_HASHTABLE_SIZE)
    22 {
    23     MOZ_COUNT_CTOR(xptiWorkingSet);
    25     gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
    26                                     "xptiWorkingSet structs");
    27 }        
    29 static PLDHashOperator
    30 xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
    31 {
    32     entry->LockedInvalidateInterfaceInfo();
    33     return PL_DHASH_NEXT;
    34 }
    36 void 
    37 XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
    38 {
    39     ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
    40     mNameTable.EnumerateRead(xpti_Invalidator, nullptr);
    41 }        
    43 XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
    44 {
    45     MOZ_COUNT_DTOR(xptiWorkingSet);
    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 }
    54 XPTArena* gXPTIStructArena;

mercurial