Bug 1049051 - Part 5: Make sDeadlockDetector access internal. r=froydnj

--HG--
extra : rebase_source : ea7ee17679ca9d616c56376d7360852c37a19249
This commit is contained in:
Eric Rahm 2014-08-12 11:44:04 -07:00
parent 9e9c81074a
commit 939cad0587
2 changed files with 37 additions and 22 deletions

View File

@ -7,9 +7,12 @@
#include "mozilla/BlockingResourceBase.h"
#ifdef DEBUG
#include "prthread.h"
#include "nsAutoPtr.h"
#include "mozilla/CondVar.h"
#include "mozilla/DeadlockDetector.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
@ -134,6 +137,34 @@ BlockingResourceBase::~BlockingResourceBase()
}
size_t
BlockingResourceBase::SizeOfDeadlockDetector(MallocSizeOf aMallocSizeOf)
{
return sDeadlockDetector ?
sDeadlockDetector->SizeOfIncludingThis(aMallocSizeOf) : 0;
}
PRStatus
BlockingResourceBase::InitStatics()
{
PR_NewThreadPrivateIndex(&sResourceAcqnChainFrontTPI, 0);
sDeadlockDetector = new DDT();
if (!sDeadlockDetector) {
NS_RUNTIMEABORT("can't allocate deadlock detector");
}
return PR_SUCCESS;
}
void
BlockingResourceBase::Shutdown()
{
delete sDeadlockDetector;
sDeadlockDetector = 0;
}
void
BlockingResourceBase::CheckAcquire()
{

View File

@ -17,11 +17,8 @@
#ifdef DEBUG
#include "prinit.h"
#include "prthread.h"
#include "nsStringGlue.h"
#include "mozilla/DeadlockDetector.h"
#include "nsXPCOM.h"
#endif
@ -31,6 +28,9 @@
namespace mozilla {
#ifdef DEBUG
template <class T> class DeadlockDetector;
#endif
/**
* BlockingResourceBase
@ -53,11 +53,7 @@ public:
#ifdef DEBUG
static size_t
SizeOfDeadlockDetector(MallocSizeOf aMallocSizeOf)
{
return sDeadlockDetector ?
sDeadlockDetector->SizeOfIncludingThis(aMallocSizeOf) : 0;
}
SizeOfDeadlockDetector(MallocSizeOf aMallocSizeOf);
/**
* Print
@ -260,15 +256,7 @@ private:
*
* *NOT* thread safe.
*/
static PRStatus InitStatics()
{
PR_NewThreadPrivateIndex(&sResourceAcqnChainFrontTPI, 0);
sDeadlockDetector = new DDT();
if (!sDeadlockDetector) {
NS_RUNTIMEABORT("can't allocate deadlock detector");
}
return PR_SUCCESS;
}
static PRStatus InitStatics();
/**
* Shutdown
@ -276,11 +264,7 @@ private:
*
* *NOT* thread safe.
*/
static void Shutdown()
{
delete sDeadlockDetector;
sDeadlockDetector = 0;
}
static void Shutdown();
# ifdef MOZILLA_INTERNAL_API
// so it can call BlockingResourceBase::Shutdown()