mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1523949 - part 2 - switch BlockingResourceBase to MOZ_THREAD_LOCAL; r=erahm,emilio
This change results in somewhat nicer code and should be slightly more performant.
This commit is contained in:
parent
0d56a7008a
commit
628d7fba21
@ -380,6 +380,7 @@ opaque-types = [
|
||||
# don't align properly on Linux 32-bit
|
||||
"mozilla::SchedulerGroup", # Non-standard-layout packing of field into superclass
|
||||
"mozilla::detail::GkAtoms", # https://bugzilla.mozilla.org/show_bug.cgi?id=1517685
|
||||
"mozilla::detail::ThreadLocal.*",
|
||||
]
|
||||
|
||||
# All cbindgen-types are in mod "structs::root::mozilla".
|
||||
|
@ -44,7 +44,7 @@ const char* const BlockingResourceBase::kResourceTypeName[] = {
|
||||
#ifdef DEBUG
|
||||
|
||||
PRCallOnceType BlockingResourceBase::sCallOnce;
|
||||
unsigned BlockingResourceBase::sResourceAcqnChainFrontTPI = (unsigned)-1;
|
||||
MOZ_THREAD_LOCAL(BlockingResourceBase*) BlockingResourceBase::sResourceAcqnChainFront;
|
||||
BlockingResourceBase::DDT* BlockingResourceBase::sDeadlockDetector;
|
||||
|
||||
void BlockingResourceBase::StackWalkCallback(uint32_t aFrameNumber, void* aPc,
|
||||
@ -230,7 +230,7 @@ size_t BlockingResourceBase::SizeOfDeadlockDetector(
|
||||
}
|
||||
|
||||
PRStatus BlockingResourceBase::InitStatics() {
|
||||
PR_NewThreadPrivateIndex(&sResourceAcqnChainFrontTPI, 0);
|
||||
MOZ_ASSERT(sResourceAcqnChainFront.init());
|
||||
sDeadlockDetector = new DDT();
|
||||
if (!sDeadlockDetector) {
|
||||
MOZ_CRASH("can't allocate deadlock detector");
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_BlockingResourceBase_h
|
||||
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/ThreadLocal.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
@ -152,8 +153,7 @@ class BlockingResourceBase {
|
||||
* resource acquired.
|
||||
*/
|
||||
static BlockingResourceBase* ResourceChainFront() {
|
||||
return (BlockingResourceBase*)PR_GetThreadPrivate(
|
||||
sResourceAcqnChainFrontTPI);
|
||||
return sResourceAcqnChainFront.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ class BlockingResourceBase {
|
||||
*/
|
||||
void ResourceChainAppend(BlockingResourceBase* aPrev) {
|
||||
mChainPrev = aPrev;
|
||||
PR_SetThreadPrivate(sResourceAcqnChainFrontTPI, this);
|
||||
sResourceAcqnChainFront.set(this);
|
||||
} // NS_NEEDS_RESOURCE(this)
|
||||
|
||||
/**
|
||||
@ -186,7 +186,7 @@ class BlockingResourceBase {
|
||||
*/
|
||||
void ResourceChainRemove() {
|
||||
NS_ASSERTION(this == ResourceChainFront(), "not at chain front");
|
||||
PR_SetThreadPrivate(sResourceAcqnChainFrontTPI, mChainPrev);
|
||||
sResourceAcqnChainFront.set(mChainPrev);
|
||||
} // NS_NEEDS_RESOURCE(this)
|
||||
|
||||
/**
|
||||
@ -280,11 +280,10 @@ class BlockingResourceBase {
|
||||
static PRCallOnceType sCallOnce;
|
||||
|
||||
/**
|
||||
* sResourceAcqnChainFrontTPI
|
||||
* Thread-private index to the front of each thread's resource
|
||||
* Thread-private pointer to the front of each thread's resource
|
||||
* acquisition chain.
|
||||
*/
|
||||
static unsigned sResourceAcqnChainFrontTPI;
|
||||
static MOZ_THREAD_LOCAL(BlockingResourceBase*) sResourceAcqnChainFront;
|
||||
|
||||
/**
|
||||
* sDeadlockDetector
|
||||
|
Loading…
Reference in New Issue
Block a user