Bug 556214, parts 1 and 1.1: Rename Monitor to ReentrantMonitor and fix existing Monitor users. r=roc

--HG--
rename : xpcom/glue/Monitor.h => xpcom/glue/ReentrantMonitor.h
This commit is contained in:
Chris Jones 2011-04-29 14:21:57 -05:00
parent c95d8badae
commit 31aa2c4e77
85 changed files with 780 additions and 790 deletions

View File

@ -39,7 +39,7 @@
#ifndef VideoUtils_h
#define VideoUtils_h
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
// This file contains stuff we'd rather put elsewhere, but which is
// dependent on other changes which we don't want to wait for. We plan to
@ -64,13 +64,13 @@
namespace mozilla {
/**
* MonitorAutoExit
* Exit the Monitor when it enters scope, and enters it when it leaves
* ReentrantMonitorAutoExit
* Exit the ReentrantMonitor when it enters scope, and enters it when it leaves
* scope.
*
* MUCH PREFERRED to bare calls to Monitor.Exit and Enter.
* MUCH PREFERRED to bare calls to ReentrantMonitor.Exit and Enter.
*/
class NS_STACK_CLASS MonitorAutoExit
class NS_STACK_CLASS ReentrantMonitorAutoExit
{
public:
/**
@ -79,31 +79,30 @@ public:
* acquires the lock. The lock must be held before constructing
* this object!
*
* @param aMonitor A valid mozilla::Monitor* returned by
* mozilla::Monitor::NewMonitor. It must be
* already locked.
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
* must be already locked.
**/
MonitorAutoExit(mozilla::Monitor &aMonitor) :
mMonitor(&aMonitor)
ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor) :
mReentrantMonitor(&aReentrantMonitor)
{
NS_ASSERTION(mMonitor, "null monitor");
mMonitor->AssertCurrentThreadIn();
mMonitor->Exit();
NS_ASSERTION(mReentrantMonitor, "null monitor");
mReentrantMonitor->AssertCurrentThreadIn();
mReentrantMonitor->Exit();
}
~MonitorAutoExit(void)
~ReentrantMonitorAutoExit(void)
{
mMonitor->Enter();
mReentrantMonitor->Enter();
}
private:
MonitorAutoExit();
MonitorAutoExit(const MonitorAutoExit&);
MonitorAutoExit& operator =(const MonitorAutoExit&);
ReentrantMonitorAutoExit();
ReentrantMonitorAutoExit(const ReentrantMonitorAutoExit&);
ReentrantMonitorAutoExit& operator =(const ReentrantMonitorAutoExit&);
static void* operator new(size_t) CPP_THROW_NEW;
static void operator delete(void*);
mozilla::Monitor* mMonitor;
ReentrantMonitor* mReentrantMonitor;
};
} // namespace mozilla

View File

@ -84,7 +84,7 @@ nsAudioAvailableEventManager::nsAudioAvailableEventManager(nsBuiltinDecoder* aDe
mSignalBufferLength(mDecoder->GetFrameBufferLength()),
mNewSignalBufferLength(mSignalBufferLength),
mSignalBufferPosition(0),
mMonitor("media.audioavailableeventmanager")
mReentrantMonitor("media.audioavailableeventmanager")
{
MOZ_COUNT_CTOR(nsAudioAvailableEventManager);
}
@ -102,7 +102,7 @@ void nsAudioAvailableEventManager::Init(PRUint32 aChannels, PRUint32 aRate)
void nsAudioAvailableEventManager::DispatchPendingEvents(PRUint64 aCurrentTime)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
while (mPendingEvents.Length() > 0) {
nsAudioAvailableEventRunner* e =
@ -120,7 +120,7 @@ void nsAudioAvailableEventManager::QueueWrittenAudioData(SoundDataValue* aAudioD
PRUint32 aAudioDataLength,
PRUint64 aEndTimeSampleOffset)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRUint32 currentBufferSize = mNewSignalBufferLength;
if (currentBufferSize == 0) {
@ -202,7 +202,7 @@ void nsAudioAvailableEventManager::QueueWrittenAudioData(SoundDataValue* aAudioD
void nsAudioAvailableEventManager::Clear()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mPendingEvents.Clear();
mSignalBufferPosition = 0;
@ -210,7 +210,7 @@ void nsAudioAvailableEventManager::Clear()
void nsAudioAvailableEventManager::Drain(PRUint64 aEndTime)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// Force all pending events to go now.
for (PRUint32 i = 0; i < mPendingEvents.Length(); ++i) {
@ -240,7 +240,7 @@ void nsAudioAvailableEventManager::Drain(PRUint64 aEndTime)
void nsAudioAvailableEventManager::SetSignalBufferLength(PRUint32 aLength)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mNewSignalBufferLength = aLength;
}

View File

@ -105,8 +105,9 @@ private:
// between the state machine and audio threads.
nsTArray< nsCOMPtr<nsIRunnable> > mPendingEvents;
// Monitor for shared access to mPendingEvents queue or buffer length.
Monitor mMonitor;
// ReentrantMonitor for shared access to mPendingEvents queue or
// buffer length.
ReentrantMonitor mReentrantMonitor;
};
#endif

View File

@ -40,7 +40,6 @@
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/PAudioChild.h"
#include "mozilla/dom/AudioChild.h"
#include "mozilla/Monitor.h"
#include "nsXULAppAPI.h"
using namespace mozilla::dom;

View File

@ -61,7 +61,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsBuiltinDecoder, nsIObserver)
void nsBuiltinDecoder::Pause()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mPlayState == PLAY_STATE_SEEKING || mPlayState == PLAY_STATE_ENDED) {
mNextState = PLAY_STATE_PAUSED;
return;
@ -96,7 +96,7 @@ nsBuiltinDecoder::nsBuiltinDecoder() :
mRequestedSeekTime(-1.0),
mDuration(-1),
mSeekable(PR_TRUE),
mMonitor("media.decoder"),
mReentrantMonitor("media.decoder"),
mPlayState(PLAY_STATE_PAUSED),
mNextState(PLAY_STATE_PAUSED),
mResourceLoaded(PR_FALSE),
@ -195,7 +195,7 @@ nsresult nsBuiltinDecoder::Load(nsMediaStream* aStream,
// Hold the lock while we do this to set proper lock ordering
// expectations for dynamic deadlock detectors: decoder lock(s)
// should be grabbed before the cache lock
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsresult rv = aStream->Open(aStreamListener);
if (NS_FAILED(rv)) {
@ -217,7 +217,7 @@ nsresult nsBuiltinDecoder::Load(nsMediaStream* aStream,
return NS_ERROR_FAILURE;
}
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mDecoderStateMachine->SetSeekable(mSeekable);
mDecoderStateMachine->SetDuration(mDuration);
@ -237,7 +237,7 @@ nsresult nsBuiltinDecoder::RequestFrameBufferLength(PRUint32 aLength)
nsresult res = nsMediaDecoder::RequestFrameBufferLength(aLength);
NS_ENSURE_SUCCESS(res,res);
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mDecoderStateMachine) {
mDecoderStateMachine->SetFrameBufferLength(aLength);
}
@ -259,7 +259,7 @@ nsresult nsBuiltinDecoder::StartStateMachineThread()
nsresult nsBuiltinDecoder::Play()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsresult res = StartStateMachineThread();
NS_ENSURE_SUCCESS(res,res);
if (mPlayState == PLAY_STATE_SEEKING) {
@ -276,7 +276,7 @@ nsresult nsBuiltinDecoder::Play()
nsresult nsBuiltinDecoder::Seek(double aTime)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (aTime < 0.0)
return NS_ERROR_FAILURE;
@ -356,7 +356,7 @@ void nsBuiltinDecoder::MetadataLoaded(PRUint32 aChannels,
// to fulfill a seek, otherwise we'll get multiple metadataloaded events.
PRBool notifyElement = PR_TRUE;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
// Duration has changed so we should recompute playback rate
UpdatePlaybackRate();
@ -382,7 +382,7 @@ void nsBuiltinDecoder::MetadataLoaded(PRUint32 aChannels,
// Only inform the element of FirstFrameLoaded if not doing a load() in order
// to fulfill a seek, otherwise we'll get multiple loadedfirstframe events.
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRBool resourceIsLoaded = !mResourceLoaded && mStream &&
mStream->IsDataCachedToEndOfStream(mDecoderPosition);
if (mElement && notifyElement) {
@ -421,7 +421,7 @@ void nsBuiltinDecoder::ResourceLoaded()
{
// If we are seeking or loading then the resource loaded notification we get
// should be ignored, since it represents the end of the seek request.
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mIgnoreProgressData || mResourceLoaded || mPlayState == PLAY_STATE_LOADING)
return;
@ -504,7 +504,7 @@ nsBuiltinDecoder::GetStatistics()
"Should be on main or state machine thread.");
Statistics result;
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mStream) {
result.mDownloadRate =
mStream->GetDownloadRate(&result.mDownloadRateReliable);
@ -531,7 +531,7 @@ nsBuiltinDecoder::GetStatistics()
double nsBuiltinDecoder::ComputePlaybackRate(PRPackedBool* aReliable)
{
GetMonitor().AssertCurrentThreadIn();
GetReentrantMonitor().AssertCurrentThreadIn();
NS_ASSERTION(NS_IsMainThread() || IsCurrentThread(mStateMachineThread),
"Should be on main or state machine thread.");
@ -547,7 +547,7 @@ void nsBuiltinDecoder::UpdatePlaybackRate()
{
NS_ASSERTION(NS_IsMainThread() || IsCurrentThread(mStateMachineThread),
"Should be on main or state machine thread.");
GetMonitor().AssertCurrentThreadIn();
GetReentrantMonitor().AssertCurrentThreadIn();
if (!mStream)
return;
PRPackedBool reliable;
@ -594,7 +594,7 @@ void nsBuiltinDecoder::NotifyDownloadEnded(nsresult aStatus)
}
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
UpdatePlaybackRate();
}
@ -609,7 +609,7 @@ void nsBuiltinDecoder::NotifyDownloadEnded(nsresult aStatus)
void nsBuiltinDecoder::NotifyBytesConsumed(PRInt64 aBytes)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(OnStateMachineThread() || mDecoderStateMachine->OnDecodeThread(),
"Should be on play state machine or decode thread.");
if (!mIgnoreProgressData) {
@ -663,7 +663,7 @@ void nsBuiltinDecoder::SeekingStopped()
PRBool seekWasAborted = PR_FALSE;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// An additional seek was requested while the current seek was
// in operation.
@ -696,7 +696,7 @@ void nsBuiltinDecoder::SeekingStoppedAtEnd()
PRBool fireEnded = PR_FALSE;
PRBool seekWasAborted = PR_FALSE;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// An additional seek was requested while the current seek was
// in operation.
@ -736,14 +736,14 @@ void nsBuiltinDecoder::SeekingStarted()
void nsBuiltinDecoder::ChangeState(PlayState aState)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mNextState == aState) {
mNextState = PLAY_STATE_PAUSED;
}
if (mPlayState == PLAY_STATE_SHUTDOWN) {
mMonitor.NotifyAll();
mReentrantMonitor.NotifyAll();
return;
}
@ -772,7 +772,7 @@ void nsBuiltinDecoder::ChangeState(PlayState aState)
/* No action needed */
break;
}
mMonitor.NotifyAll();
mReentrantMonitor.NotifyAll();
}
void nsBuiltinDecoder::PlaybackPositionChanged()
@ -786,7 +786,7 @@ void nsBuiltinDecoder::PlaybackPositionChanged()
// Control the scope of the monitor so it is not
// held while the timeupdate and the invalidate is run.
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mDecoderStateMachine) {
mCurrentTime = mDecoderStateMachine->GetCurrentTime();
mDecoderStateMachine->ClearPositionChangeFlag();
@ -807,7 +807,7 @@ void nsBuiltinDecoder::PlaybackPositionChanged()
void nsBuiltinDecoder::DurationChanged()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRInt64 oldDuration = mDuration;
mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
// Duration has changed so we should recompute playback rate
@ -824,7 +824,7 @@ void nsBuiltinDecoder::SetDuration(double aDuration)
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
mDuration = static_cast<PRInt64>(NS_round(aDuration * static_cast<double>(USECS_PER_S)));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mDecoderStateMachine) {
mDecoderStateMachine->SetDuration(mDuration);
}
@ -838,7 +838,7 @@ void nsBuiltinDecoder::SetSeekable(PRBool aSeekable)
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
mSeekable = aSeekable;
if (mDecoderStateMachine) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mDecoderStateMachine->SetSeekable(aSeekable);
}
}
@ -864,7 +864,7 @@ void nsBuiltinDecoder::Resume(PRBool aForceBuffering)
mStream->Resume();
}
if (aForceBuffering) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mDecoderStateMachine->StartBuffering();
}
}
@ -898,6 +898,6 @@ void nsBuiltinDecoder::MoveLoadsToBackground()
void nsBuiltinDecoder::UpdatePlaybackOffset(PRInt64 aOffset)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mPlaybackPosition = NS_MAX(aOffset, mPlaybackPosition);
}

View File

@ -212,7 +212,7 @@ Shutdown when destroying the nsBuiltinDecoder object.
#include "nsMediaStream.h"
#include "nsMediaDecoder.h"
#include "nsHTMLMediaElement.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
class nsAudioStream;
@ -319,7 +319,7 @@ class nsBuiltinDecoder : public nsMediaDecoder
NS_DECL_NSIOBSERVER
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
// Enumeration for the valid play states (see mPlayState)
enum PlayState {
@ -434,8 +434,8 @@ class nsBuiltinDecoder : public nsMediaDecoder
// Returns the monitor for other threads to synchronise access to
// state.
Monitor& GetMonitor() {
return mMonitor;
ReentrantMonitor& GetReentrantMonitor() {
return mReentrantMonitor;
}
// Constructs the time ranges representing what segments of the media
@ -594,7 +594,7 @@ public:
// Position to seek to when the seek notification is received by the
// decode thread. Written by the main thread and read via the
// decode thread. Synchronised using mMonitor. If the
// decode thread. Synchronised using mReentrantMonitor. If the
// value is negative then no seek has been requested. When a seek is
// started this is reset to negative.
double mRequestedSeekTime;
@ -622,13 +622,13 @@ public:
// Stream of media data.
nsAutoPtr<nsMediaStream> mStream;
// Monitor for detecting when the video play state changes. A call
// ReentrantMonitor for detecting when the video play state changes. A call
// to Wait on this monitor will block the thread until the next
// state change.
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
// Set to one of the valid play states. It is protected by the
// monitor mMonitor. This monitor must be acquired when reading or
// monitor mReentrantMonitor. This monitor must be acquired when reading or
// writing the state. Any change to the state on the main thread
// must call NotifyAll on the monitor so the decode thread can wake up.
PlayState mPlayState;

View File

@ -207,7 +207,7 @@ VideoData* VideoData::Create(nsVideoInfo& aInfo,
}
nsBuiltinDecoderReader::nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder)
: mMonitor("media.decoderreader"),
: mReentrantMonitor("media.decoderreader"),
mDecoder(aDecoder)
{
MOZ_COUNT_CTOR(nsBuiltinDecoderReader);
@ -279,7 +279,7 @@ Data* nsBuiltinDecoderReader::DecodeToFirstData(DecodeFn aDecodeFn,
PRBool eof = PR_FALSE;
while (!eof && aQueue.GetSize() == 0) {
{
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
return nsnull;
}
@ -301,8 +301,8 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
PRBool skip = PR_FALSE;
eof = !DecodeVideoFrame(skip, 0);
{
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
return NS_ERROR_FAILURE;
}
@ -326,8 +326,8 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
}
}
{
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
return NS_ERROR_FAILURE;
}
@ -342,8 +342,8 @@ nsresult nsBuiltinDecoderReader::DecodeToTarget(PRInt64 aTarget)
while (!eof && mAudioQueue.GetSize() == 0) {
eof = !DecodeAudioData();
{
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
return NS_ERROR_FAILURE;
}

View File

@ -46,7 +46,7 @@
#include "mozilla/TimeStamp.h"
#include "nsSize.h"
#include "nsRect.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
class nsBuiltinDecoderStateMachine;
@ -297,12 +297,12 @@ class MediaQueueDeallocator : public nsDequeFunctor {
template <class T> class MediaQueue : private nsDeque {
public:
typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
MediaQueue()
: nsDeque(new MediaQueueDeallocator<T>()),
mMonitor("mediaqueue"),
mReentrantMonitor("mediaqueue"),
mEndOfStream(0)
{}
@ -311,52 +311,52 @@ template <class T> class MediaQueue : private nsDeque {
}
inline PRInt32 GetSize() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return nsDeque::GetSize();
}
inline void Push(T* aItem) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsDeque::Push(aItem);
}
inline void PushFront(T* aItem) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsDeque::PushFront(aItem);
}
inline T* Pop() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return static_cast<T*>(nsDeque::Pop());
}
inline T* PopFront() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return static_cast<T*>(nsDeque::PopFront());
}
inline T* Peek() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return static_cast<T*>(nsDeque::Peek());
}
inline T* PeekFront() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return static_cast<T*>(nsDeque::PeekFront());
}
inline void Empty() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsDeque::Empty();
}
inline void Erase() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsDeque::Erase();
}
void Reset() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
while (GetSize() > 0) {
T* x = PopFront();
delete x;
@ -365,7 +365,7 @@ template <class T> class MediaQueue : private nsDeque {
}
PRBool AtEndOfStream() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return GetSize() == 0 && mEndOfStream;
}
@ -373,19 +373,19 @@ template <class T> class MediaQueue : private nsDeque {
// This happens when the media stream has been completely decoded. Note this
// does not mean that the corresponding stream has finished playback.
PRBool IsFinished() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mEndOfStream;
}
// Informs the media queue that it won't be receiving any more samples.
void Finish() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mEndOfStream = PR_TRUE;
}
// Returns the approximate number of microseconds of samples in the queue.
PRInt64 Duration() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (GetSize() < 2) {
return 0;
}
@ -395,7 +395,7 @@ template <class T> class MediaQueue : private nsDeque {
}
private:
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
// PR_TRUE when we've decoded the last frame of data in the
// bitstream for which we're queueing sample-data.
@ -410,8 +410,8 @@ private:
// this class.
class nsBuiltinDecoderReader : public nsRunnable {
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder);
~nsBuiltinDecoderReader();
@ -503,7 +503,7 @@ protected:
// The lock which we hold whenever we read or decode. This ensures the thread
// safety of the reader and its data fields.
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
// Reference to the owning decoder object. Do not hold the
// reader's monitor when accessing this.

View File

@ -175,7 +175,7 @@ nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDe
nsBuiltinDecoderReader* aReader) :
mDecoder(aDecoder),
mState(DECODER_STATE_DECODING_METADATA),
mAudioMonitor("media.audiostream"),
mAudioReentrantMonitor("media.audiostream"),
mCbCrSize(0),
mPlayDuration(0),
mStartTime(-1),
@ -204,7 +204,7 @@ nsBuiltinDecoderStateMachine::~nsBuiltinDecoderStateMachine()
}
PRBool nsBuiltinDecoderStateMachine::HasFutureAudio() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
NS_ASSERTION(HasAudio(), "Should only call HasFutureAudio() when we have audio");
// We've got audio ready to play if:
// 1. We've not completed playback of audio, and
@ -216,14 +216,14 @@ PRBool nsBuiltinDecoderStateMachine::HasFutureAudio() const {
}
PRBool nsBuiltinDecoderStateMachine::HaveNextFrameData() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return (!HasAudio() || HasFutureAudio()) &&
(!HasVideo() || mReader->mVideoQueue.GetSize() > 0);
}
PRInt64 nsBuiltinDecoderStateMachine::GetDecodedAudioDuration() {
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
PRInt64 audioDecoded = mReader->mAudioQueue.Duration();
if (mAudioEndTime != -1) {
audioDecoded += mAudioEndTime - GetMediaTime();
@ -267,7 +267,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
MediaQueue<VideoData>& videoQueue = mReader->mVideoQueue;
MediaQueue<SoundData>& audioQueue = mReader->mAudioQueue;
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
PRBool videoPlaying = HasVideo();
PRBool audioPlaying = HasAudio();
@ -323,7 +323,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
TimeDuration decodeTime;
{
PRInt64 currentTime = GetMediaTime();
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
TimeStamp start = TimeStamp::Now();
videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
decodeTime = TimeStamp::Now() - start;
@ -345,13 +345,13 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
if (audioPlaying &&
(GetDecodedAudioDuration() < ampleAudioThreshold || audioQueue.GetSize() == 0))
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
audioPlaying = mReader->DecodeAudioData();
}
// Notify to ensure that the AudioLoop() is not waiting, in case it was
// waiting for more audio to be decoded.
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
if (!IsPlaying()) {
// Update the ready state, so that the play DOM events fire. We only
@ -387,7 +387,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
mState != DECODER_STATE_SEEKING)
{
mState = DECODER_STATE_COMPLETED;
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
LOG(PR_LOG_DEBUG, ("Shutting down DecodeLoop this=%p", this));
@ -395,7 +395,7 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
PRBool nsBuiltinDecoderStateMachine::IsPlaying()
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return !mPlayStartTime.IsNull();
}
@ -412,7 +412,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
PRInt32 minWriteSamples = -1;
PRInt64 samplesAtLastSleep = 0;
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mAudioCompleted = PR_FALSE;
audioStartTime = mAudioStartTime;
channels = mInfo.mAudioChannels;
@ -424,7 +424,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
// Wait while we're not playing, and we're not shutting down, or we're
// playing and we've got no audio to play.
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
NS_ASSERTION(mState != DECODER_STATE_DECODING_METADATA,
"Should have meta data before audio started playing.");
while (mState != DECODER_STATE_SHUTDOWN &&
@ -455,7 +455,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
}
if (setVolume || minWriteSamples == -1) {
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (mAudioStream) {
if (setVolume) {
mAudioStream->SetVolume(volume);
@ -508,7 +508,7 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
audioDuration += PlayFromAudioQueue(sampleTime, channels);
}
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
PRInt64 playedUsecs;
if (!SamplesToUsecs(audioDuration, rate, playedUsecs)) {
NS_WARNING("Int overflow calculating playedUsecs");
@ -545,14 +545,14 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
{
// Last sample pushed to audio hardware, wait for the audio to finish,
// before the audio thread terminates.
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (mAudioStream) {
PRBool seeking = PR_FALSE;
PRInt64 oldPosition = -1;
{
MonitorAutoExit audioExit(mAudioMonitor);
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit audioExit(mAudioReentrantMonitor);
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
PRInt64 position = GetMediaTime();
while (oldPosition != position &&
mAudioEndTime - position > 0 &&
@ -579,12 +579,12 @@ void nsBuiltinDecoderStateMachine::AudioLoop()
LOG(PR_LOG_DEBUG, ("%p Reached audio stream end.", mDecoder));
}
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mAudioCompleted = PR_TRUE;
UpdateReadyState();
// Kick the decode and state machine threads; they may be sleeping waiting
// for this to finish.
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
LOG(PR_LOG_DEBUG, ("Audio stream finished playing, audio thread exit"));
}
@ -594,7 +594,7 @@ PRUint32 nsBuiltinDecoderStateMachine::PlaySilence(PRUint32 aSamples,
PRUint64 aSampleOffset)
{
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (!mAudioStream || mAudioStream->IsPaused()) {
// The state machine has paused since we've released the decoder
// monitor and acquired the audio monitor. Don't write any audio.
@ -617,16 +617,16 @@ PRUint32 nsBuiltinDecoderStateMachine::PlayFromAudioQueue(PRUint64 aSampleOffset
{
nsAutoPtr<SoundData> sound(mReader->mAudioQueue.PopFront());
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
NS_WARN_IF_FALSE(IsPlaying(), "Should be playing");
// Awaken the decode loop if it's waiting for space to free up in the
// audio queue.
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
PRInt64 offset = -1;
PRUint32 samples = 0;
{
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (!mAudioStream) {
return 0;
}
@ -673,7 +673,7 @@ void nsBuiltinDecoderStateMachine::StopPlayback(eStopMode aMode)
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mDecoder->mPlaybackStatistics.Stop(TimeStamp::Now());
@ -687,8 +687,8 @@ void nsBuiltinDecoderStateMachine::StopPlayback(eStopMode aMode)
mPlayStartTime = TimeStamp();
}
if (HasAudio()) {
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (mAudioStream) {
if (aMode == AUDIO_PAUSE) {
mAudioStream->Pause();
@ -706,7 +706,7 @@ void nsBuiltinDecoderStateMachine::StartPlayback()
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
NS_ASSERTION(!IsPlaying(), "Shouldn't be playing when StartPlayback() is called");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
LOG(PR_LOG_DEBUG, ("%p StartPlayback", mDecoder));
mDecoder->mPlaybackStatistics.Start(TimeStamp::Now());
if (HasAudio()) {
@ -714,8 +714,8 @@ void nsBuiltinDecoderStateMachine::StartPlayback()
PRInt32 channels = mInfo.mAudioChannels;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
MonitorAutoEnter audioMon(mAudioMonitor);
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
if (mAudioStream) {
// We have an audiostream, so it must have been paused the last time
// StopPlayback() was called.
@ -729,14 +729,14 @@ void nsBuiltinDecoderStateMachine::StartPlayback()
}
}
mPlayStartTime = TimeStamp::Now();
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
void nsBuiltinDecoderStateMachine::UpdatePlaybackPositionInternal(PRInt64 aTime)
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
NS_ASSERTION(mStartTime >= 0, "Should have positive mStartTime");
mCurrentFrameTime = aTime - mStartTime;
@ -769,14 +769,14 @@ void nsBuiltinDecoderStateMachine::UpdatePlaybackPosition(PRInt64 aTime)
void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mPositionChangeQueued = PR_FALSE;
}
nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (IsBuffering() || IsSeeking()) {
return nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING;
} else if (HaveNextFrameData()) {
@ -788,7 +788,7 @@ nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameSt
void nsBuiltinDecoderStateMachine::SetVolume(double volume)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mVolume = volume;
}
@ -804,7 +804,7 @@ double nsBuiltinDecoderStateMachine::GetCurrentTime() const
PRInt64 nsBuiltinDecoderStateMachine::GetDuration()
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
if (mEndTime == -1 || mStartTime == -1)
return -1;
@ -815,7 +815,7 @@ void nsBuiltinDecoderStateMachine::SetDuration(PRInt64 aDuration)
{
NS_ASSERTION(NS_IsMainThread() || mDecoder->OnStateMachineThread(),
"Should be on main or state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
if (mStartTime != -1) {
mEndTime = mStartTime + aDuration;
@ -828,7 +828,7 @@ void nsBuiltinDecoderStateMachine::SetDuration(PRInt64 aDuration)
void nsBuiltinDecoderStateMachine::SetSeekable(PRBool aSeekable)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mSeekable = aSeekable;
}
@ -838,20 +838,20 @@ void nsBuiltinDecoderStateMachine::Shutdown()
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
// Once we've entered the shutdown state here there's no going back.
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
// Change state before issuing shutdown request to threads so those
// threads can start exiting cleanly during the Shutdown call.
LOG(PR_LOG_DEBUG, ("%p Changed state to SHUTDOWN", mDecoder));
mState = DECODER_STATE_SHUTDOWN;
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
void nsBuiltinDecoderStateMachine::StartDecoding()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mState != DECODER_STATE_DECODING) {
mDecodeStartTime = TimeStamp::Now();
}
@ -864,12 +864,12 @@ void nsBuiltinDecoderStateMachine::Play()
// When asked to play, switch to decoding state only if
// we are currently buffering. In other cases, we'll start playing anyway
// when the state machine notices the decoder's state change to PLAYING.
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mState == DECODER_STATE_BUFFERING) {
LOG(PR_LOG_DEBUG, ("%p Changed state from BUFFERING to DECODING", mDecoder));
mState = DECODER_STATE_DECODING;
mDecodeStartTime = TimeStamp::Now();
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
}
@ -886,7 +886,7 @@ void nsBuiltinDecoderStateMachine::ResetPlayback()
void nsBuiltinDecoderStateMachine::Seek(double aTime)
{
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
// nsBuiltinDecoder::mPlayState should be SEEKING while we seek, and
// in that case nsBuiltinDecoder shouldn't be calling us.
NS_ASSERTION(mState != DECODER_STATE_SEEKING,
@ -916,19 +916,19 @@ void nsBuiltinDecoderStateMachine::StopDecodeThreads()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mStopDecodeThreads = PR_TRUE;
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
if (mDecodeThread) {
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
mDecodeThread->Shutdown();
}
mDecodeThread = nsnull;
}
if (mAudioThread) {
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
mAudioThread->Shutdown();
}
mAudioThread = nsnull;
@ -940,7 +940,7 @@ nsBuiltinDecoderStateMachine::StartDecodeThreads()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mStopDecodeThreads = PR_FALSE;
if (!mDecodeThread && mState < DECODER_STATE_COMPLETED) {
nsresult rv = NS_NewThread(getter_AddRefs(mDecodeThread));
@ -978,7 +978,7 @@ PRInt64 nsBuiltinDecoderStateMachine::AudioDecodedUsecs() const
PRBool nsBuiltinDecoderStateMachine::HasLowDecodedData(PRInt64 aAudioUsecs) const
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
// We consider ourselves low on decoded data if we're low on audio,
// provided we've not decoded to the end of the audio stream, or
// if we're only playing video and we're low on video frames, provided
@ -1000,7 +1000,7 @@ PRBool nsBuiltinDecoderStateMachine::HasLowUndecodedData() const
PRInt64 nsBuiltinDecoderStateMachine::GetUndecodedData() const
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA,
"Must have loaded metadata for GetBuffered() to work");
nsTimeRanges buffered;
@ -1033,7 +1033,7 @@ void nsBuiltinDecoderStateMachine::SetFrameBufferLength(PRUint32 aLength)
{
NS_ASSERTION(aLength >= 512 && aLength <= 16384,
"The length must be between 512 and 16384");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
mEventManager.SetSignalBufferLength(aLength);
}
@ -1045,7 +1045,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
NS_ENSURE_TRUE(stream, NS_ERROR_NULL_POINTER);
while (PR_TRUE) {
MonitorAutoEnter mon(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
switch (mState) {
case DECODER_STATE_SHUTDOWN:
if (IsPlaying()) {
@ -1068,7 +1068,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
RenderVideoFrame(videoData, TimeStamp::Now(), display, aspect);
}
}
@ -1157,7 +1157,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
// inform the element and its users that we have no frames
// to display
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
nsCOMPtr<nsIRunnable> startEvent =
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStarted);
NS_DispatchToMainThread(startEvent, NS_DISPATCH_SYNC);
@ -1172,7 +1172,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
ResetPlayback();
nsresult res;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
// Now perform the seek. We must not hold the state machine monitor
// while we seek, since the seek decodes.
res = mReader->Seek(seekTime,
@ -1196,7 +1196,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
RenderVideoFrame(video, TimeStamp::Now(), display, aspect);
}
mReader->mVideoQueue.PopFront();
@ -1230,10 +1230,10 @@ nsresult nsBuiltinDecoderStateMachine::Run()
stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStopped);
StartDecoding();
}
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC);
}
@ -1248,7 +1248,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
{
if (IsPlaying()) {
StopPlayback(AUDIO_PAUSE);
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
TimeStamp now = TimeStamp::Now();
@ -1285,7 +1285,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
if (mState != DECODER_STATE_BUFFERING) {
// Notify to allow blocked decoder thread to continue
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
UpdateReadyState();
if (mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING) {
if (!IsPlaying()) {
@ -1329,7 +1329,7 @@ nsresult nsBuiltinDecoderStateMachine::Run()
PRInt64 clockTime = NS_MAX(mEndTime, NS_MAX(videoTime, GetAudioClock()));
UpdatePlaybackPosition(clockTime);
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::PlaybackEnded);
NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
@ -1359,7 +1359,7 @@ void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
float aAspectRatio)
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertNotCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
if (aData->mDuplicate) {
return;
@ -1385,7 +1385,7 @@ nsBuiltinDecoderStateMachine::GetAudioClock()
void nsBuiltinDecoderStateMachine::AdvanceFrame()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
// When it's time to display a frame, decode the frame and display it.
if (mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING) {
@ -1469,7 +1469,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
// Start playing now if need be.
if (!IsPlaying()) {
StartPlayback();
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
if (currentFrame) {
@ -1481,7 +1481,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
nsIntSize display = mInfo.mDisplay;
float aspect = mInfo.mPixelAspectRatio;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
// If we have video, we want to increment the clock in steps of the frame
// duration.
RenderVideoFrame(currentFrame, presTime, display, aspect);
@ -1495,7 +1495,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
// Kick the decode thread in case it filled its buffers and put itself
// to sleep.
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
// Cap the current time to the larger of the audio and video end time.
// This ensures that if we're running off the system clock, we don't
@ -1524,18 +1524,18 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
} else {
if (IsPlaying()) {
StopPlayback(AUDIO_PAUSE);
mDecoder->GetMonitor().NotifyAll();
mDecoder->GetReentrantMonitor().NotifyAll();
}
if (mState == DECODER_STATE_DECODING ||
mState == DECODER_STATE_COMPLETED) {
mDecoder->GetMonitor().Wait();
mDecoder->GetReentrantMonitor().Wait();
}
}
}
void nsBuiltinDecoderStateMachine::Wait(PRInt64 aUsecs) {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
TimeStamp end = TimeStamp::Now() + UsecsToDuration(aUsecs);
TimeStamp now;
while ((now = TimeStamp::Now()) < end &&
@ -1546,19 +1546,19 @@ void nsBuiltinDecoderStateMachine::Wait(PRInt64 aUsecs) {
if (ms == 0 || ms > PR_UINT32_MAX) {
break;
}
mDecoder->GetMonitor().Wait(PR_MillisecondsToInterval(static_cast<PRUint32>(ms)));
mDecoder->GetReentrantMonitor().Wait(PR_MillisecondsToInterval(static_cast<PRUint32>(ms)));
}
}
VideoData* nsBuiltinDecoderStateMachine::FindStartTime()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
PRInt64 startTime = 0;
mStartTime = 0;
VideoData* v = nsnull;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
v = mReader->FindStartTime(0, startTime);
}
if (startTime != 0) {
@ -1583,7 +1583,7 @@ VideoData* nsBuiltinDecoderStateMachine::FindStartTime()
void nsBuiltinDecoderStateMachine::FindEndTime()
{
NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
nsMediaStream* stream = mDecoder->GetCurrentStream();
@ -1594,7 +1594,7 @@ void nsBuiltinDecoderStateMachine::FindEndTime()
mEndTime = 0;
PRInt64 endTime = 0;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
endTime = mReader->FindEndTime(length);
}
if (endTime != -1) {
@ -1605,7 +1605,7 @@ void nsBuiltinDecoderStateMachine::FindEndTime()
}
void nsBuiltinDecoderStateMachine::UpdateReadyState() {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
nsCOMPtr<nsIRunnable> event;
switch (GetNextFrameStatus()) {
@ -1629,13 +1629,13 @@ void nsBuiltinDecoderStateMachine::LoadMetadata()
{
NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
"Should be on state machine thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
LOG(PR_LOG_DEBUG, ("Loading Media Headers"));
nsresult res;
nsVideoInfo info;
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
res = mReader->ReadMetadata(&info);
}
mInfo = info;
@ -1660,7 +1660,7 @@ PRBool nsBuiltinDecoderStateMachine::JustExitedQuickBuffering()
void nsBuiltinDecoderStateMachine::StartBuffering()
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
// Go into quick buffering mode provided we've not just left buffering using

View File

@ -118,7 +118,7 @@ not yet time to display the next frame.
#include "nsBuiltinDecoderReader.h"
#include "nsAudioAvailableEventManager.h"
#include "nsHTMLMediaElement.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
/*
The playback state machine class. This manages the decoding in the
@ -140,7 +140,7 @@ not yet time to display the next frame.
class nsBuiltinDecoderStateMachine : public nsDecoderStateMachine
{
public:
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
@ -151,7 +151,7 @@ public:
virtual nsresult Init(nsDecoderStateMachine* aCloneDonor);
State GetState()
{
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mState;
}
virtual void SetVolume(double aVolume);
@ -183,14 +183,14 @@ public:
// This is called on the state machine thread and audio thread.
// The decoder monitor must be obtained before calling this.
PRBool HasAudio() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mInfo.mHasAudio;
}
// This is called on the state machine thread and audio thread.
// The decoder monitor must be obtained before calling this.
PRBool HasVideo() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mInfo.mHasVideo;
}
@ -199,14 +199,14 @@ public:
// Must be called with the decode monitor held.
PRBool IsBuffering() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mState == nsBuiltinDecoderStateMachine::DECODER_STATE_BUFFERING;
}
// Must be called with the decode monitor held.
PRBool IsSeeking() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mState == nsBuiltinDecoderStateMachine::DECODER_STATE_SEEKING;
}
@ -243,7 +243,7 @@ public:
}
PRInt64 GetEndMediaTime() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mEndTime;
}
@ -278,7 +278,7 @@ protected:
// Returns PR_TRUE if we recently exited "quick buffering" mode.
PRBool JustExitedQuickBuffering();
// Waits on the decoder Monitor for aUsecs microseconds. If the decoder
// Waits on the decoder ReentrantMonitor for aUsecs microseconds. If the decoder
// monitor is awoken by a Notify() call, we'll continue waiting, unless
// we've moved into shutdown state. This enables us to ensure that we
// wait for a specified time, and that the myriad of Notify()s we do an
@ -389,7 +389,7 @@ protected:
// not start at 0. Note this is different to the value returned
// by GetCurrentTime(), which is in the range [0,duration].
PRInt64 GetMediaTime() const {
mDecoder->GetMonitor().AssertCurrentThreadIn();
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
return mStartTime + mCurrentFrameTime;
}
@ -402,11 +402,11 @@ protected:
// must be held when calling this. Called on the decoder thread.
PRInt64 GetDecodedAudioDuration();
// Monitor on mAudioStream. This monitor must be held in order to delete
// or use the audio stream. This stops us destroying the audio stream
// while it's being used on another thread (typically when it's being
// written to on the audio thread).
Monitor mAudioMonitor;
// ReentrantMonitor on mAudioStream. This monitor must be held in
// order to delete or use the audio stream. This stops us destroying
// the audio stream while it's being used on another thread
// (typically when it's being written to on the audio thread).
ReentrantMonitor mAudioReentrantMonitor;
// The size of the decoded YCbCr frame.
// Accessed on state machine thread.
@ -454,9 +454,9 @@ protected:
// this value. Accessed on main and state machine thread.
PRInt64 mSeekTime;
// The audio stream resource. Used on the state machine, audio, and main
// threads. You must hold the mAudioMonitor, and must NOT hold the decoder
// monitor when using the audio stream!
// The audio stream resource. Used on the state machine, audio, and
// main threads. You must hold the mAudioReentrantMonitor, and must
// NOT hold the decoder monitor when using the audio stream!
nsRefPtr<nsAudioStream> mAudioStream;
// The reader, don't call its methods with the decoder monitor held.

View File

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/XPCOM.h"
#include "nsMediaCache.h"
@ -134,7 +134,7 @@ public:
};
nsMediaCache() : mNextResourceID(1),
mMonitor("nsMediaCache.mMonitor"),
mReentrantMonitor("nsMediaCache.mReentrantMonitor"),
mFD(nsnull), mFDCurrentPos(0), mUpdateQueued(PR_FALSE)
#ifdef DEBUG
, mInUpdate(PR_FALSE)
@ -168,7 +168,7 @@ public:
void FlushInternal();
// Cache-file access methods. These are the lowest-level cache methods.
// mMonitor must be held; these can be called on any thread.
// mReentrantMonitor must be held; these can be called on any thread.
// This can return partial reads.
nsresult ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
PRInt32* aBytes);
@ -177,7 +177,7 @@ public:
// This will fail if all aLength bytes are not written
nsresult WriteCacheFile(PRInt64 aOffset, const void* aData, PRInt32 aLength);
// mMonitor must be held, called on main thread.
// mReentrantMonitor must be held, called on main thread.
// These methods are used by the stream to set up and tear down streams,
// and to handle reads and writes.
// Add aStream to the list of streams.
@ -190,7 +190,7 @@ public:
void AllocateAndWriteBlock(nsMediaCacheStream* aStream, const void* aData,
nsMediaCacheStream::ReadMode aMode);
// mMonitor must be held; can be called on any thread
// mReentrantMonitor must be held; can be called on any thread
// Notify the cache that a seek has been requested. Some blocks may
// need to change their class between PLAYED_BLOCK and READAHEAD_BLOCK.
// This does not trigger channel seeks directly, the next Update()
@ -227,7 +227,7 @@ public:
void Verify() {}
#endif
Monitor& GetMonitor() { return mMonitor; }
ReentrantMonitor& GetReentrantMonitor() { return mReentrantMonitor; }
/**
* An iterator that makes it easy to iterate through all streams that
@ -350,7 +350,7 @@ protected:
// The monitor protects all the data members here. Also, off-main-thread
// readers that need to block will Wait() on this monitor. When new
// data becomes available in the cache, we NotifyAll() on this monitor.
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
// The Blocks describing the cache entries.
nsTArray<Block> mIndex;
// The file descriptor of the cache file. The file will be deleted
@ -608,7 +608,7 @@ nsMediaCache::Flush()
void
nsMediaCache::FlushInternal()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 blockIndex = 0; blockIndex < mIndex.Length(); ++blockIndex) {
FreeBlock(blockIndex);
@ -663,7 +663,7 @@ nsresult
nsMediaCache::ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
PRInt32* aBytes)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
if (!mFD)
return NS_ERROR_FAILURE;
@ -685,7 +685,7 @@ nsMediaCache::ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
nsresult
nsMediaCache::ReadCacheFileAllBytes(PRInt64 aOffset, void* aData, PRInt32 aLength)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRInt64 offset = aOffset;
PRInt32 count = aLength;
@ -708,7 +708,7 @@ nsMediaCache::ReadCacheFileAllBytes(PRInt64 aOffset, void* aData, PRInt32 aLengt
nsresult
nsMediaCache::WriteCacheFile(PRInt64 aOffset, const void* aData, PRInt32 aLength)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
if (!mFD)
return NS_ERROR_FAILURE;
@ -749,7 +749,7 @@ PRInt32
nsMediaCache::FindBlockForIncomingData(TimeStamp aNow,
nsMediaCacheStream* aStream)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRInt32 blockIndex = FindReusableBlock(aNow, aStream,
aStream->mChannelOffset/BLOCK_SIZE, PR_INT32_MAX);
@ -792,7 +792,7 @@ nsMediaCache::AppendMostReusableBlock(BlockList* aBlockList,
nsTArray<PRUint32>* aResult,
PRInt32 aBlockIndexLimit)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRInt32 blockIndex = aBlockList->GetLastBlock();
if (blockIndex < 0)
@ -816,7 +816,7 @@ nsMediaCache::FindReusableBlock(TimeStamp aNow,
PRInt32 aForStreamBlock,
PRInt32 aMaxSearchBlockIndex)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRUint32 length = PR_MIN(PRUint32(aMaxSearchBlockIndex), mIndex.Length());
@ -910,7 +910,7 @@ nsMediaCache::GetBlockOwner(PRInt32 aBlockIndex, nsMediaCacheStream* aStream)
void
nsMediaCache::SwapBlocks(PRInt32 aBlockIndex1, PRInt32 aBlockIndex2)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
Block* block1 = &mIndex[aBlockIndex1];
Block* block2 = &mIndex[aBlockIndex2];
@ -990,7 +990,7 @@ nsMediaCache::AddBlockOwnerAsReadahead(PRInt32 aBlockIndex,
void
nsMediaCache::FreeBlock(PRInt32 aBlock)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
Block* block = &mIndex[aBlock];
if (block->mOwners.IsEmpty()) {
@ -1013,7 +1013,7 @@ nsMediaCache::FreeBlock(PRInt32 aBlock)
TimeDuration
nsMediaCache::PredictNextUse(TimeStamp aNow, PRInt32 aBlock)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
NS_ASSERTION(!IsBlockFree(aBlock), "aBlock is free");
Block* block = &mIndex[aBlock];
@ -1063,7 +1063,7 @@ nsMediaCache::PredictNextUse(TimeStamp aNow, PRInt32 aBlock)
TimeDuration
nsMediaCache::PredictNextUseForIncomingData(nsMediaCacheStream* aStream)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRInt64 bytesAhead = aStream->mChannelOffset - aStream->mStreamOffset;
if (bytesAhead <= -BLOCK_SIZE) {
@ -1091,7 +1091,7 @@ nsMediaCache::Update()
nsAutoTArray<StreamAction,10> actions;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mUpdateQueued = PR_FALSE;
#ifdef DEBUG
mInUpdate = PR_TRUE;
@ -1373,7 +1373,7 @@ nsMediaCache::Update()
// Close the streams that failed due to error. This will cause all
// client Read and Seek operations on those streams to fail. Blocked
// Reads will also be woken up.
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
stream->CloseInternal(mon);
}
}
@ -1394,7 +1394,7 @@ public:
void
nsMediaCache::QueueUpdate()
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
// Queuing an update while we're in an update raises a high risk of
// triggering endless events
@ -1411,7 +1411,7 @@ nsMediaCache::QueueUpdate()
void
nsMediaCache::Verify()
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
mFreeBlocks.Verify();
for (PRUint32 i = 0; i < mStreams.Length(); ++i) {
@ -1443,7 +1443,7 @@ void
nsMediaCache::InsertReadaheadBlock(BlockOwner* aBlockOwner,
PRInt32 aBlockIndex)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
// Find the last block whose stream block is before aBlockIndex's
// stream block, and insert after it
@ -1469,7 +1469,7 @@ void
nsMediaCache::AllocateAndWriteBlock(nsMediaCacheStream* aStream, const void* aData,
nsMediaCacheStream::ReadMode aMode)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRInt32 streamBlockIndex = aStream->mChannelOffset/BLOCK_SIZE;
@ -1547,7 +1547,7 @@ nsMediaCache::OpenStream(nsMediaCacheStream* aStream)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
LOG(PR_LOG_DEBUG, ("Stream %p opened", aStream));
mStreams.AppendElement(aStream);
aStream->mResourceID = mNextResourceID++;
@ -1561,7 +1561,7 @@ nsMediaCache::ReleaseStream(nsMediaCacheStream* aStream)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
LOG(PR_LOG_DEBUG, ("Stream %p closed", aStream));
mStreams.RemoveElement(aStream);
}
@ -1569,7 +1569,7 @@ nsMediaCache::ReleaseStream(nsMediaCacheStream* aStream)
void
nsMediaCache::ReleaseStreamBlocks(nsMediaCacheStream* aStream)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
// XXX scanning the entire stream doesn't seem great, if not much of it
// is cached, but the only easy alternative is to scan the entire cache
@ -1609,7 +1609,7 @@ nsMediaCache::NoteBlockUsage(nsMediaCacheStream* aStream, PRInt32 aBlockIndex,
nsMediaCacheStream::ReadMode aMode,
TimeStamp aNow)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
if (aBlockIndex < 0) {
// this block is not in the cache yet
@ -1641,7 +1641,7 @@ nsMediaCache::NoteBlockUsage(nsMediaCacheStream* aStream, PRInt32 aBlockIndex,
void
nsMediaCache::NoteSeek(nsMediaCacheStream* aStream, PRInt64 aOldOffset)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
if (aOldOffset < aStream->mStreamOffset) {
// We seeked forward. Convert blocks from readahead to played.
@ -1697,7 +1697,7 @@ nsMediaCacheStream::NotifyDataLength(PRInt64 aLength)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
mStreamLength = aLength;
}
@ -1706,7 +1706,7 @@ nsMediaCacheStream::NotifyDataStarted(PRInt64 aOffset)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
NS_WARN_IF_FALSE(aOffset == mChannelOffset,
"Server is giving us unexpected offset");
mChannelOffset = aOffset;
@ -1757,7 +1757,7 @@ nsMediaCacheStream::NotifyDataReceived(PRInt64 aSize, const char* aData,
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
PRInt64 size = aSize;
const char* data = aData;
@ -1826,7 +1826,7 @@ nsMediaCacheStream::NotifyDataEnded(nsresult aStatus)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
PRInt32 blockOffset = PRInt32(mChannelOffset%BLOCK_SIZE);
if (blockOffset > 0) {
@ -1864,7 +1864,7 @@ nsMediaCacheStream::~nsMediaCacheStream()
void
nsMediaCacheStream::SetSeekable(PRBool aIsSeekable)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
NS_ASSERTION(mIsSeekable || aIsSeekable ||
mChannelOffset == 0, "channel offset must be zero when we become non-seekable");
mIsSeekable = aIsSeekable;
@ -1876,7 +1876,7 @@ nsMediaCacheStream::SetSeekable(PRBool aIsSeekable)
PRBool
nsMediaCacheStream::IsSeekable()
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
return mIsSeekable;
}
@ -1885,7 +1885,7 @@ nsMediaCacheStream::Close()
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
CloseInternal(mon);
// Queue an Update since we may have created more free space. Don't do
// it from CloseInternal since that gets called by Update() itself
@ -1894,7 +1894,7 @@ nsMediaCacheStream::Close()
}
void
nsMediaCacheStream::CloseInternal(MonitorAutoEnter& aMonitor)
nsMediaCacheStream::CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor)
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
@ -1903,13 +1903,13 @@ nsMediaCacheStream::CloseInternal(MonitorAutoEnter& aMonitor)
mClosed = PR_TRUE;
gMediaCache->ReleaseStreamBlocks(this);
// Wake up any blocked readers
aMonitor.NotifyAll();
aReentrantMonitor.NotifyAll();
}
void
nsMediaCacheStream::Pin()
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
++mPinCount;
// Queue an Update since we may no longer want to read more into the
// cache, if this stream's block have become non-evictable
@ -1919,7 +1919,7 @@ nsMediaCacheStream::Pin()
void
nsMediaCacheStream::Unpin()
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
NS_ASSERTION(mPinCount > 0, "Unbalanced Unpin");
--mPinCount;
// Queue an Update since we may be able to read more into the
@ -1930,28 +1930,28 @@ nsMediaCacheStream::Unpin()
PRInt64
nsMediaCacheStream::GetLength()
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
return mStreamLength;
}
PRInt64
nsMediaCacheStream::GetNextCachedData(PRInt64 aOffset)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
return GetNextCachedDataInternal(aOffset);
}
PRInt64
nsMediaCacheStream::GetCachedDataEnd(PRInt64 aOffset)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
return GetCachedDataEndInternal(aOffset);
}
PRBool
nsMediaCacheStream::IsDataCachedToEndOfStream(PRInt64 aOffset)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (mStreamLength < 0)
return PR_FALSE;
return GetCachedDataEndInternal(aOffset) >= mStreamLength;
@ -1960,7 +1960,7 @@ nsMediaCacheStream::IsDataCachedToEndOfStream(PRInt64 aOffset)
PRInt64
nsMediaCacheStream::GetCachedDataEndInternal(PRInt64 aOffset)
{
gMediaCache->GetMonitor().AssertCurrentThreadIn();
gMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
PRUint32 startBlockIndex = aOffset/BLOCK_SIZE;
PRUint32 blockIndex = startBlockIndex;
while (blockIndex < mBlocks.Length() && mBlocks[blockIndex] != -1) {
@ -1983,7 +1983,7 @@ nsMediaCacheStream::GetCachedDataEndInternal(PRInt64 aOffset)
PRInt64
nsMediaCacheStream::GetNextCachedDataInternal(PRInt64 aOffset)
{
gMediaCache->GetMonitor().AssertCurrentThreadIn();
gMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
if (aOffset == mStreamLength)
return -1;
@ -2030,7 +2030,7 @@ nsMediaCacheStream::GetNextCachedDataInternal(PRInt64 aOffset)
void
nsMediaCacheStream::SetReadMode(ReadMode aMode)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (aMode == mCurrentMode)
return;
mCurrentMode = aMode;
@ -2041,7 +2041,7 @@ void
nsMediaCacheStream::SetPlaybackRate(PRUint32 aBytesPerSecond)
{
NS_ASSERTION(aBytesPerSecond > 0, "Zero playback rate not allowed");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (aBytesPerSecond == mPlaybackBytesPerSecond)
return;
mPlaybackBytesPerSecond = aBytesPerSecond;
@ -2053,7 +2053,7 @@ nsMediaCacheStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (mClosed)
return NS_ERROR_FAILURE;
@ -2087,7 +2087,7 @@ nsMediaCacheStream::Tell()
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
return mStreamOffset;
}
@ -2096,7 +2096,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (mClosed)
return NS_ERROR_FAILURE;
@ -2181,7 +2181,7 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer,
PRInt64 aOffset,
PRInt64 aCount)
{
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
if (mClosed)
return NS_ERROR_FAILURE;
@ -2259,7 +2259,7 @@ nsMediaCacheStream::InitAsClone(nsMediaCacheStream* aOriginal)
mResourceID = aOriginal->mResourceID;
// Grab cache blocks from aOriginal as readahead blocks for our stream
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
mPrincipal = aOriginal->mPrincipal;
mStreamLength = aOriginal->mStreamLength;
@ -2289,7 +2289,7 @@ nsresult nsMediaCacheStream::GetCachedRanges(nsTArray<nsByteRange>& aRanges)
{
// Take the monitor, so that the cached data ranges can't grow while we're
// trying to loop over them.
MonitorAutoEnter mon(gMediaCache->GetMonitor());
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
// We must be pinned while running this, otherwise the cached data ranges may
// shrink while we're trying to loop over them.

View File

@ -45,7 +45,7 @@
class nsByteRange;
namespace mozilla {
class MonitorAutoEnter;
class ReentrantMonitorAutoEnter;
}
/**
@ -211,7 +211,7 @@ class nsMediaChannelStream;
* This class can be directly embedded as a value.
*/
class nsMediaCacheStream {
typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
public:
enum {
@ -430,10 +430,10 @@ private:
PRInt64 GetNextCachedDataInternal(PRInt64 aOffset);
// A helper function to do the work of closing the stream. Assumes
// that the cache monitor is held. Main thread only.
// aMonitor is the nsAutoMonitor wrapper holding the cache monitor.
// aReentrantMonitor is the nsAutoReentrantMonitor wrapper holding the cache monitor.
// This is used to NotifyAll to wake up threads that might be
// blocked on reading from this stream.
void CloseInternal(MonitorAutoEnter& aMonitor);
void CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor);
// Update mPrincipal given that data has been received from aPrincipal
void UpdatePrincipal(nsIPrincipal* aPrincipal);

View File

@ -47,7 +47,7 @@
#include "gfxRect.h"
#include "nsITimer.h"
#include "ImageLayers.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
class nsHTMLMediaElement;
@ -89,7 +89,7 @@ public:
typedef mozilla::TimeDuration TimeDuration;
typedef mozilla::layers::ImageContainer ImageContainer;
typedef mozilla::layers::Image Image;
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
typedef mozilla::Mutex Mutex;
nsMediaDecoder();
@ -190,7 +190,7 @@ public:
public:
FrameStatistics() :
mMonitor("nsMediaDecoder::FrameStats"),
mReentrantMonitor("nsMediaDecoder::FrameStats"),
mParsedFrames(0),
mDecodedFrames(0),
mPresentedFrames(0) {}
@ -198,14 +198,14 @@ public:
// Returns number of frames which have been parsed from the media.
// Can be called on any thread.
PRUint32 GetParsedFrames() {
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mParsedFrames;
}
// Returns the number of parsed frames which have been decoded.
// Can be called on any thread.
PRUint32 GetDecodedFrames() {
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mDecodedFrames;
}
@ -213,7 +213,7 @@ public:
// pipeline for painting ("presented").
// Can be called on any thread.
PRUint32 GetPresentedFrames() {
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mPresentedFrames;
}
@ -222,7 +222,7 @@ public:
void NotifyDecodedFrames(PRUint32 aParsed, PRUint32 aDecoded) {
if (aParsed == 0 && aDecoded == 0)
return;
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mParsedFrames += aParsed;
mDecodedFrames += aDecoded;
}
@ -230,25 +230,25 @@ public:
// Increments the presented frame counters.
// Can be called on any thread.
void NotifyPresentedFrame() {
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
++mPresentedFrames;
}
private:
// Monitor to protect access of playback statistics.
Monitor mMonitor;
// ReentrantMonitor to protect access of playback statistics.
ReentrantMonitor mReentrantMonitor;
// Number of frames parsed and demuxed from media.
// Access protected by mStatsMonitor.
// Access protected by mStatsReentrantMonitor.
PRUint32 mParsedFrames;
// Number of parsed frames which were actually decoded.
// Access protected by mStatsMonitor.
// Access protected by mStatsReentrantMonitor.
PRUint32 mDecodedFrames;
// Number of decoded frames which were actually sent down the rendering
// pipeline to be painted ("presented"). Access protected by mStatsMonitor.
// pipeline to be painted ("presented"). Access protected by mStatsReentrantMonitor.
PRUint32 mPresentedFrames;
};

View File

@ -144,7 +144,7 @@ nsresult nsOggReader::ResetDecode()
}
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// Discard any previously buffered packets/pages.
ogg_sync_reset(&mOggState);
@ -173,7 +173,7 @@ static PRBool DoneReadingHeaders(nsTArray<nsOggCodecState*>& aBitstreams) {
nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on play state machine thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// We read packets until all bitstreams have read all their header packets.
// We record the offset of the first non-header page so that we know
@ -338,8 +338,8 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
}
PRInt64 duration = 0;
if (NS_SUCCEEDED(mSkeletonState->GetDuration(tracks, duration))) {
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
mDecoder->GetStateMachine()->SetDuration(duration);
LOG(PR_LOG_DEBUG, ("Got duration from Skeleton index %lld", duration));
}
@ -412,7 +412,7 @@ nsresult nsOggReader::DecodeVorbis(nsTArray<nsAutoPtr<SoundData> >& aChunks,
PRBool nsOggReader::DecodeAudioData()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on playback or decode thread.");
NS_ASSERTION(mVorbisState!=0, "Need Vorbis state to decode audio");
@ -568,7 +568,7 @@ nsresult nsOggReader::DecodeTheora(nsTArray<nsAutoPtr<VideoData> >& aFrames,
// Need the monitor to be held to be able to use mInfo. This
// is held by our caller.
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
VideoData *v = VideoData::Create(mInfo,
mDecoder->GetImageContainer(),
mPageOffset,
@ -593,7 +593,7 @@ nsresult nsOggReader::DecodeTheora(nsTArray<nsAutoPtr<VideoData> >& aFrames,
PRBool nsOggReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
PRInt64 aTimeThreshold)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine or AV thread.");
@ -801,7 +801,7 @@ PRInt64 nsOggReader::ReadOggPage(ogg_page* aPage)
{
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on play state machine or decode thread.");
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
int ret = 0;
while((ret = ogg_sync_pageseek(&mOggState, aPage)) <= 0) {
@ -842,7 +842,7 @@ PRBool nsOggReader::ReadOggPacket(nsOggCodecState* aCodecState,
{
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on play state machine or decode thread.");
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
if (!aCodecState || !aCodecState->mActive) {
return PR_FALSE;
@ -917,7 +917,7 @@ VideoData* nsOggReader::FindStartTime(PRInt64 aOffset,
PRInt64 nsOggReader::FindEndTime(PRInt64 aEndOffset)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
NS_ASSERTION(mDataOffset > 0,
@ -1056,7 +1056,7 @@ nsresult nsOggReader::GetSeekRanges(nsTArray<SeekRange>& aRanges)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
nsTArray<nsByteRange> cached;
nsresult res = mDecoder->GetCurrentStream()->GetCachedRanges(cached);
NS_ENSURE_SUCCESS(res, res);
@ -1236,8 +1236,8 @@ nsresult nsOggReader::SeekInBufferedRange(PRInt64 aTarget,
PRBool skip = PR_FALSE;
eof = !DecodeVideoFrame(skip, 0);
{
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
return NS_ERROR_FAILURE;
}
@ -1316,7 +1316,7 @@ nsresult nsOggReader::Seek(PRInt64 aTarget,
PRInt64 aEndTime,
PRInt64 aCurrentTime)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
LOG(PR_LOG_DEBUG, ("%p About to seek to %lldms", mDecoder, aTarget));
@ -1336,8 +1336,8 @@ nsresult nsOggReader::Seek(PRInt64 aTarget,
NS_ASSERTION(aStartTime != -1, "mStartTime should be known");
{
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
mDecoder->UpdatePlaybackPosition(aStartTime);
}
} else if (CanDecodeToTarget(aTarget, aCurrentTime)) {

View File

@ -80,13 +80,13 @@ public:
virtual PRBool HasAudio()
{
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mVorbisState != 0 && mVorbisState->mActive;
}
virtual PRBool HasVideo()
{
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mTheoraState != 0 && mTheoraState->mActive;
}
@ -98,7 +98,7 @@ private:
PRBool HasSkeleton()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mSkeletonState != 0 && mSkeletonState->mActive;
}

View File

@ -153,7 +153,7 @@ nsresult nsWaveReader::Init(nsBuiltinDecoderReader* aCloneDonor)
nsresult nsWaveReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on state machine thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRBool loaded = LoadRIFFChunk() && LoadFormatChunk() && FindDataOffset();
if (!loaded) {
@ -167,8 +167,8 @@ nsresult nsWaveReader::ReadMetadata(nsVideoInfo* aInfo)
*aInfo = mInfo;
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
mDecoder->GetStateMachine()->SetDuration(
static_cast<PRInt64>(BytesToTime(GetDataLength()) * USECS_PER_S));
@ -178,7 +178,7 @@ nsresult nsWaveReader::ReadMetadata(nsVideoInfo* aInfo)
PRBool nsWaveReader::DecodeAudioData()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine thread or decode thread.");
@ -246,7 +246,7 @@ PRBool nsWaveReader::DecodeAudioData()
PRBool nsWaveReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
PRInt64 aTimeThreshold)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine or decode thread.");
@ -255,7 +255,7 @@ PRBool nsWaveReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
LOG(PR_LOG_DEBUG, ("%p About to seek to %lld", mDecoder, aTarget));
@ -477,7 +477,7 @@ nsWaveReader::LoadFormatChunk()
return PR_FALSE;
}
MonitorAutoEnter monitor(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
mSampleRate = rate;
mChannels = channels;
mSampleSize = sampleSize;
@ -509,7 +509,7 @@ nsWaveReader::FindDataOffset()
return PR_FALSE;
}
MonitorAutoEnter monitor(mDecoder->GetMonitor());
ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
mWaveLength = length;
mWavePCMOffset = PRUint32(offset);
return PR_TRUE;

View File

@ -41,7 +41,7 @@
#include "nsTimeRanges.h"
#include "nsThreadUtils.h"
using mozilla::MonitorAutoEnter;
using mozilla::ReentrantMonitorAutoEnter;
static const double NS_PER_S = 1e9;
@ -66,7 +66,7 @@ VIntLength(unsigned char aFirstByte, PRUint32* aMask)
void nsWebMBufferedParser::Append(const unsigned char* aBuffer, PRUint32 aLength,
nsTArray<nsWebMTimeDataOffset>& aMapping,
Monitor& aMonitor)
ReentrantMonitor& aReentrantMonitor)
{
static const unsigned char CLUSTER_ID[] = { 0x1f, 0x43, 0xb6, 0x75 };
static const unsigned char TIMECODE_ID = 0xe7;
@ -171,7 +171,7 @@ void nsWebMBufferedParser::Append(const unsigned char* aBuffer, PRUint32 aLength
// It's possible we've parsed this data before, so avoid inserting
// duplicate nsWebMTimeDataOffset entries.
{
MonitorAutoEnter mon(aMonitor);
ReentrantMonitorAutoEnter mon(aReentrantMonitor);
PRUint32 idx;
if (!aMapping.GreatestIndexLtEq(mBlockOffset, idx)) {
nsWebMTimeDataOffset entry(mBlockOffset, mClusterTimecode + mBlockTimecode);
@ -214,7 +214,7 @@ void nsWebMBufferedState::CalculateBufferedForRange(nsTimeRanges* aBuffered,
PRUint64 aTimecodeScale,
PRInt64 aStartTimeOffsetNS)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// Find the first nsWebMTimeDataOffset at or after aStartOffset.
PRUint32 start;
@ -286,7 +286,7 @@ void nsWebMBufferedState::NotifyDataArrived(const char* aBuffer, PRUint32 aLengt
mRangeParsers[idx].Append(reinterpret_cast<const unsigned char*>(aBuffer),
aLength,
mTimeMapping,
mMonitor);
mReentrantMonitor);
// Merge parsers with overlapping regions and clean up the remnants.
PRUint32 i = 0;

View File

@ -40,10 +40,10 @@
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
class nsTimeRanges;
using mozilla::Monitor;
using mozilla::ReentrantMonitor;
// Stores a stream byte offset and the scaled timecode of the block at
// that offset. The timecode must be scaled by the stream's timecode
@ -80,10 +80,10 @@ struct nsWebMBufferedParser
// Steps the parser through aLength bytes of data. Always consumes
// aLength bytes. Updates mCurrentOffset before returning. Acquires
// aMonitor before using aMapping.
// aReentrantMonitor before using aMapping.
void Append(const unsigned char* aBuffer, PRUint32 aLength,
nsTArray<nsWebMTimeDataOffset>& aMapping,
Monitor& aMonitor);
ReentrantMonitor& aReentrantMonitor);
bool operator==(PRInt64 aOffset) const {
return mCurrentOffset == aOffset;
@ -216,7 +216,7 @@ class nsWebMBufferedState
NS_INLINE_DECL_REFCOUNTING(nsWebMBufferedState)
public:
nsWebMBufferedState() : mMonitor("nsWebMBufferedState") {
nsWebMBufferedState() : mReentrantMonitor("nsWebMBufferedState") {
MOZ_COUNT_CTOR(nsWebMBufferedState);
}
@ -232,7 +232,7 @@ public:
private:
// Synchronizes access to the mTimeMapping array.
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
// Sorted (by offset) map of data offsets to timecodes. Populated
// on the main thread as data is received and parsed by nsWebMBufferedParsers.

View File

@ -211,7 +211,7 @@ void nsWebMReader::Cleanup()
nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
{
NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on state machine thread.");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nestegg_io io;
io.read = webm_read;
@ -226,8 +226,8 @@ nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
uint64_t duration = 0;
r = nestegg_duration(mContext, &duration);
if (r == 0) {
MonitorAutoExit exitReaderMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
mDecoder->GetStateMachine()->SetDuration(duration / NS_PER_USEC);
}
@ -413,7 +413,7 @@ ogg_packet nsWebMReader::InitOggPacket(unsigned char* aData,
PRBool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
int r = 0;
unsigned int count = 0;
@ -591,7 +591,7 @@ nsReturnRef<NesteggPacketHolder> nsWebMReader::NextPacket(TrackType aTrackType)
PRBool nsWebMReader::DecodeAudioData()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine thread or decode thread.");
nsAutoRef<NesteggPacketHolder> holder(NextPacket(AUDIO));
@ -606,7 +606,7 @@ PRBool nsWebMReader::DecodeAudioData()
PRBool nsWebMReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
PRInt64 aTimeThreshold)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
"Should be on state machine or decode thread.");
@ -654,8 +654,8 @@ PRBool nsWebMReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
}
mVideoPackets.PushFront(next_holder.disown());
} else {
MonitorAutoExit exitMon(mMonitor);
MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
ReentrantMonitorAutoExit exitMon(mReentrantMonitor);
ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
nsBuiltinDecoderStateMachine* s =
static_cast<nsBuiltinDecoderStateMachine*>(mDecoder->GetStateMachine());
PRInt64 endTime = s->GetEndMediaTime();
@ -756,7 +756,7 @@ PRBool nsWebMReader::CanDecodeToTarget(PRInt64 aTarget,
nsresult nsWebMReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime,
PRInt64 aCurrentTime)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mDecoder->OnStateMachineThread(),
"Should be on state machine thread.");
LOG(PR_LOG_DEBUG, ("%p About to seek to %lldms", mDecoder, aTarget));

View File

@ -143,13 +143,13 @@ public:
virtual PRBool HasAudio()
{
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mHasAudio;
}
virtual PRBool HasVideo()
{
mozilla::MonitorAutoEnter mon(mMonitor);
mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mHasVideo;
}

View File

@ -48,7 +48,7 @@ NS_IMPL_THREADSAFE_RELEASE(AudioChild);
AudioChild::AudioChild()
: mLastSampleOffset(-1),
mLastSampleOffsetTime(0),
mAudioMonitor("media.audiochild.monitor"),
mAudioReentrantMonitor("AutoChild.mReentrantMonitor"),
mIPCOpen(PR_TRUE),
mDrained(PR_FALSE)
{
@ -78,18 +78,18 @@ AudioChild::RecvSampleOffsetUpdate(const PRInt64& offset,
bool
AudioChild::RecvDrainDone()
{
mozilla::MonitorAutoEnter mon(mAudioMonitor);
ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
mDrained = PR_TRUE;
mAudioMonitor.NotifyAll();
mAudioReentrantMonitor.NotifyAll();
return true;
}
void
AudioChild::WaitForDrain()
{
mozilla::MonitorAutoEnter mon(mAudioMonitor);
ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
while (!mDrained && mIPCOpen) {
mAudioMonitor.Wait();
mAudioReentrantMonitor.Wait();
}
}

View File

@ -41,7 +41,7 @@
#define mozilla_dom_AudioChild_h
#include "mozilla/dom/PAudioChild.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
namespace mozilla {
namespace dom {
@ -67,7 +67,7 @@ class AudioChild : public PAudioChild
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
PRInt64 mLastSampleOffset, mLastSampleOffsetTime;
mozilla::Monitor mAudioMonitor;
mozilla::ReentrantMonitor mAudioReentrantMonitor;
PRPackedBool mIPCOpen;
PRPackedBool mDrained;
};

View File

@ -109,7 +109,6 @@ static const char* sClipboardTextFlavors[] = { kUnicodeMime };
using namespace mozilla::ipc;
using namespace mozilla::net;
using namespace mozilla::places;
using mozilla::MonitorAutoEnter;
using mozilla::unused; // heh
using base::KillProcess;
@ -330,8 +329,7 @@ ContentParent::DestroyTestShell(TestShellParent* aTestShell)
}
ContentParent::ContentParent()
: mMonitor("ContentParent::mMonitor")
, mGeolocationWatchID(-1)
: mGeolocationWatchID(-1)
, mRunToCompletionDepth(0)
, mShouldCallUnblockChild(false)
, mIsAlive(true)

View File

@ -47,7 +47,6 @@
#include "nsIObserver.h"
#include "nsIThreadInternal.h"
#include "mozilla/Monitor.h"
#include "nsNetUtil.h"
#include "nsIPrefService.h"
#include "nsIPermissionManager.h"
@ -207,8 +206,6 @@ private:
const PRUint32& aFlags,
const nsCString& aCategory);
mozilla::Monitor mMonitor;
GeckoChildProcessHost* mSubprocess;
PRInt32 mGeolocationWatchID;

View File

@ -373,7 +373,7 @@ public:
PRBool aClearQueue) {
NS_ASSERTION(aRunnable, "Null pointer!");
gDOMThreadService->mMonitor.AssertCurrentThreadIn();
gDOMThreadService->mReentrantMonitor.AssertCurrentThreadIn();
if (NS_LIKELY(!aTimeoutInterval)) {
NS_ADDREF(aRunnable);
@ -466,7 +466,7 @@ public:
JS_SetContextPrivate(cx, NULL);
}
MonitorAutoEnter mon(gDOMThreadService->mMonitor);
ReentrantMonitorAutoEnter mon(gDOMThreadService->mReentrantMonitor);
killWorkerWhenDone = mKillWorkerWhenDone;
gDOMThreadService->WorkerComplete(this);
mon.NotifyAll();
@ -496,7 +496,7 @@ protected:
while (1) {
nsCOMPtr<nsIRunnable> runnable;
{
MonitorAutoEnter mon(gDOMThreadService->mMonitor);
ReentrantMonitorAutoEnter mon(gDOMThreadService->mReentrantMonitor);
runnable = dont_AddRef((nsIRunnable*)mRunnables.PopFront());
@ -539,7 +539,7 @@ protected:
// Set at construction
nsRefPtr<nsDOMWorker> mWorker;
// Protected by mMonitor
// Protected by mReentrantMonitor
nsDeque mRunnables;
nsCOMPtr<nsIRunnable> mCloseRunnable;
PRIntervalTime mCloseTimeoutInterval;
@ -573,7 +573,7 @@ DOMWorkerOperationCallback(JSContext* aCx)
JS_FlushCaches(aCx);
for (;;) {
MonitorAutoEnter mon(worker->Pool()->GetMonitor());
ReentrantMonitorAutoEnter mon(worker->Pool()->GetReentrantMonitor());
// There's a small chance that the worker was canceled after our check
// above in which case we shouldn't wait here. We're guaranteed not to
@ -729,7 +729,7 @@ DOMWorkerErrorReporter(JSContext* aCx,
*/
nsDOMThreadService::nsDOMThreadService()
: mMonitor("nsDOMThreadServer.mMonitor"),
: mReentrantMonitor("nsDOMThreadServer.mReentrantMonitor"),
mNavigatorStringsLoaded(PR_FALSE)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -884,7 +884,7 @@ nsDOMThreadService::Cleanup()
CancelWorkersForGlobal(nsnull);
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(!mPools.Count(), "Live workers left!");
mPools.Clear();
@ -949,7 +949,7 @@ nsDOMThreadService::Dispatch(nsDOMWorker* aWorker,
nsRefPtr<nsDOMWorkerRunnable> workerRunnable;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mWorkersInProgress.Get(aWorker, getter_AddRefs(workerRunnable))) {
workerRunnable->PutRunnable(aRunnable, aTimeoutInterval, aClearQueue);
@ -972,7 +972,7 @@ nsDOMThreadService::Dispatch(nsDOMWorker* aWorker,
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch runnable to thread pool!");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// We exited the monitor after inserting the runnable into the table so make
// sure we're removing the right one!
@ -1000,7 +1000,7 @@ nsDOMThreadService::SetWorkerTimeout(nsDOMWorker* aWorker,
NS_ASSERTION(mThreadPool, "Dispatch called after 'xpcom-shutdown'!");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<nsDOMWorkerRunnable> workerRunnable;
if (mWorkersInProgress.Get(aWorker, getter_AddRefs(workerRunnable))) {
@ -1011,7 +1011,7 @@ nsDOMThreadService::SetWorkerTimeout(nsDOMWorker* aWorker,
void
nsDOMThreadService::WorkerComplete(nsDOMWorkerRunnable* aRunnable)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
#ifdef DEBUG
nsRefPtr<nsDOMWorker>& debugWorker = aRunnable->mWorker;
@ -1028,7 +1028,7 @@ nsDOMThreadService::WorkerComplete(nsDOMWorkerRunnable* aRunnable)
PRBool
nsDOMThreadService::QueueSuspendedWorker(nsDOMWorkerRunnable* aRunnable)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
#ifdef DEBUG
{
@ -1085,7 +1085,7 @@ already_AddRefed<nsDOMWorkerPool>
nsDOMThreadService::GetPoolForGlobal(nsIScriptGlobalObject* aGlobalObject,
PRBool aRemove)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<nsDOMWorkerPool> pool;
mPools.Get(aGlobalObject, getter_AddRefs(pool));
@ -1100,7 +1100,7 @@ nsDOMThreadService::GetPoolForGlobal(nsIScriptGlobalObject* aGlobalObject,
void
nsDOMThreadService::TriggerOperationCallbackForPool(nsDOMWorkerPool* aPool)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
// See if we need to trigger the operation callback on any currently running
// contexts.
@ -1117,7 +1117,7 @@ nsDOMThreadService::TriggerOperationCallbackForPool(nsDOMWorkerPool* aPool)
void
nsDOMThreadService::RescheduleSuspendedWorkerForPool(nsDOMWorkerPool* aPool)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
PRUint32 count = mSuspendedWorkers.Length();
if (!count) {
@ -1161,7 +1161,7 @@ nsDOMThreadService::CancelWorkersForGlobal(nsIScriptGlobalObject* aGlobalObject)
if (pool) {
pool->Cancel();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
TriggerOperationCallbackForPool(pool);
RescheduleSuspendedWorkerForPool(pool);
@ -1177,7 +1177,7 @@ nsDOMThreadService::SuspendWorkersForGlobal(nsIScriptGlobalObject* aGlobalObject
if (pool) {
pool->Suspend();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
TriggerOperationCallbackForPool(pool);
}
}
@ -1191,7 +1191,7 @@ nsDOMThreadService::ResumeWorkersForGlobal(nsIScriptGlobalObject* aGlobalObject)
if (pool) {
pool->Resume();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
TriggerOperationCallbackForPool(pool);
RescheduleSuspendedWorkerForPool(pool);
@ -1203,7 +1203,7 @@ nsDOMThreadService::NoteEmptyPool(nsDOMWorkerPool* aPool)
{
NS_ASSERTION(aPool, "Null pointer!");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mPools.Remove(aPool->ScriptGlobalObject());
}
@ -1222,7 +1222,7 @@ nsDOMThreadService::ChangeThreadPoolMaxThreads(PRInt16 aDelta)
{
NS_ENSURE_ARG(aDelta == 1 || aDelta == -1);
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRUint32 currentThreadCount;
nsresult rv = mThreadPool->GetThreadLimit(&currentThreadCount);
@ -1260,7 +1260,7 @@ nsDOMThreadService::NoteThreadsafeContractId(const nsACString& aContractId,
{
NS_ASSERTION(!aContractId.IsEmpty(), "Empty contract id!");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
#ifdef DEBUG
{
@ -1281,7 +1281,7 @@ nsDOMThreadService::GetContractIdThreadsafeStatus(const nsACString& aContractId)
{
NS_ASSERTION(!aContractId.IsEmpty(), "Empty contract id!");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRBool isThreadsafe;
if (mThreadsafeContractIDs.Get(aContractId, &isThreadsafe)) {
@ -1392,7 +1392,7 @@ nsDOMThreadService::OnThreadCreated()
return NS_ERROR_FAILURE;
}
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
#ifdef DEBUG
JSContext** newContext =
@ -1421,7 +1421,7 @@ nsDOMThreadService::OnThreadShuttingDown()
NS_WARN_IF_FALSE(cx, "Thread died with no context?");
if (cx) {
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mJSContexts.RemoveElement(cx);
}
@ -1467,7 +1467,7 @@ nsDOMThreadService::RegisterWorker(nsDOMWorker* aWorker,
nsRefPtr<nsDOMWorkerPool> pool;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mThreadPool) {
// Shutting down!
@ -1516,7 +1516,7 @@ nsDOMThreadService::RegisterWorker(nsDOMWorker* aWorker,
rv = pool->Init();
NS_ENSURE_SUCCESS(rv, rv);
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRBool success = mPools.Put(aGlobalObject, pool);
NS_ENSURE_TRUE(success, NS_ERROR_OUT_OF_MEMORY);

View File

@ -47,7 +47,7 @@
// Other includes
#include "jsapi.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "nsDataHashtable.h"
@ -183,22 +183,22 @@ private:
// Maps nsIScriptGlobalObject* to nsDOMWorkerPool.
nsRefPtrHashtable<nsVoidPtrHashKey, nsDOMWorkerPool> mPools;
// mMonitor protects all access to mWorkersInProgress and
// mReentrantMonitor protects all access to mWorkersInProgress and
// mCreationsInProgress.
mozilla::Monitor mMonitor;
mozilla::ReentrantMonitor mReentrantMonitor;
// A map from nsDOMWorkerThread to nsDOMWorkerRunnable.
nsRefPtrHashtable<nsVoidPtrHashKey, nsDOMWorkerRunnable> mWorkersInProgress;
// A list of active JSContexts that we've created. Always protected with
// mMonitor.
// mReentrantMonitor.
nsTArray<JSContext*> mJSContexts;
// A list of worker runnables that were never started because the worker was
// suspended. Always protected with mMonitor.
// suspended. Always protected with mReentrantMonitor.
nsTArray<nsDOMWorkerRunnable*> mSuspendedWorkers;
// Always protected with mMonitor.
// Always protected with mReentrantMonitor.
nsDataHashtable<nsCStringHashKey, PRBool> mThreadsafeContractIDs;
nsString mAppName;

View File

@ -2392,7 +2392,7 @@ nsDOMWorker::FireCloseRunnable(PRIntervalTime aTimeoutInterval,
}
if (wakeUp) {
MonitorAutoEnter mon(mPool->GetMonitor());
ReentrantMonitorAutoEnter mon(mPool->GetReentrantMonitor());
mon.NotifyAll();
}

View File

@ -67,7 +67,7 @@ nsDOMWorkerPool::nsDOMWorkerPool(nsIScriptGlobalObject* aGlobalObject,
nsIDocument* aDocument)
: mParentGlobal(aGlobalObject),
mParentDocument(aDocument),
mMonitor("nsDOMWorkerPool.mMonitor"),
mReentrantMonitor("nsDOMWorkerPool.mReentrantMonitor"),
mCanceled(PR_FALSE),
mSuspended(PR_FALSE),
mWindowID(aDocument ? aDocument->OuterWindowID() : 0)
@ -110,7 +110,7 @@ nsDOMWorkerPool::NoteWorker(nsDOMWorker* aWorker)
PRBool suspendWorker;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mCanceled) {
return NS_ERROR_ABORT;
@ -137,7 +137,7 @@ nsDOMWorkerPool::NoteDyingWorker(nsDOMWorker* aWorker)
PRBool removeFromThreadService = PR_FALSE;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mWorkers.Contains(aWorker), "Worker from a different pool?!");
mWorkers.RemoveElement(aWorker);
@ -156,7 +156,7 @@ nsDOMWorkerPool::NoteDyingWorker(nsDOMWorker* aWorker)
void
nsDOMWorkerPool::GetWorkers(nsTArray<nsDOMWorker*>& aArray)
{
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
NS_ASSERTION(!aArray.Length(), "Should be empty!");
#ifdef DEBUG
@ -174,7 +174,7 @@ nsDOMWorkerPool::Cancel()
nsAutoTArray<nsDOMWorker*, 10> workers;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mCanceled = PR_TRUE;
@ -186,7 +186,7 @@ nsDOMWorkerPool::Cancel()
for (PRUint32 index = 0; index < count; index++) {
workers[index]->Cancel();
}
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.NotifyAll();
}
}
@ -198,7 +198,7 @@ nsDOMWorkerPool::Suspend()
nsAutoTArray<nsDOMWorker*, 10> workers;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(!mSuspended, "Suspended more than once!");
mSuspended = PR_TRUE;
@ -219,7 +219,7 @@ nsDOMWorkerPool::Resume()
nsAutoTArray<nsDOMWorker*, 10> workers;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_ASSERTION(mSuspended, "Not suspended!");
mSuspended = PR_FALSE;
@ -232,7 +232,7 @@ nsDOMWorkerPool::Resume()
for (PRUint32 index = 0; index < count; index++) {
workers[index]->Resume();
}
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.NotifyAll();
}
}

View File

@ -42,7 +42,7 @@
// Other includes
#include "jsapi.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsCOMPtr.h"
#include "nsStringGlue.h"
#include "nsTArray.h"
@ -55,7 +55,7 @@ class nsIScriptGlobalObject;
class nsDOMWorkerPool
{
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
public:
nsDOMWorkerPool(nsIScriptGlobalObject* aGlobalObject,
@ -81,8 +81,8 @@ public:
nsresult NoteWorker(nsDOMWorker* aWorker);
void NoteDyingWorker(nsDOMWorker* aWorker);
Monitor& GetMonitor() {
return mMonitor;
ReentrantMonitor& GetReentrantMonitor() {
return mReentrantMonitor;
}
const PRUint64 WindowID() const {
@ -106,8 +106,8 @@ private:
// independently of the owning pool and other workers.
nsTArray<nsDOMWorker*> mWorkers;
// Monitor for suspending and resuming workers.
Monitor mMonitor;
// ReentrantMonitor for suspending and resuming workers.
ReentrantMonitor mReentrantMonitor;
PRPackedBool mCanceled;
PRPackedBool mSuspended;

View File

@ -43,7 +43,7 @@
#include "gfxPattern.h"
#include "nsThreadUtils.h"
#include "nsCoreAnimationSupport.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/TimeStamp.h"
namespace mozilla {
@ -134,7 +134,7 @@ class THEBES_API ImageContainer {
public:
ImageContainer() :
mMonitor("ImageContainer"),
mReentrantMonitor("ImageContainer.mReentrantMonitor"),
mPaintCount(0),
mPreviousImagePainted(PR_FALSE)
{}
@ -146,8 +146,8 @@ public:
* Picks the "best" format from the list and creates an Image of that
* format.
* Returns null if this backend does not support any of the formats.
* Can be called on any thread. This method takes mMonitor when accessing
* thread-shared state.
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
*/
virtual already_AddRefed<Image> CreateImage(const Image::Format* aFormats,
PRUint32 aNumFormats) = 0;
@ -155,8 +155,8 @@ public:
/**
* Set an Image as the current image to display. The Image must have
* been created by this ImageContainer.
* Can be called on any thread. This method takes mMonitor when accessing
* thread-shared state.
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
*
* The Image data must not be modified after this method is called!
*/
@ -167,10 +167,10 @@ public:
* This has to add a reference since otherwise there are race conditions
* where the current image is destroyed before the caller can add
* a reference.
* Can be called on any thread. This method takes mMonitor when accessing
* thread-shared state.
* Implementations must call CurrentImageChanged() while holding mMonitor.
*
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
* Implementations must call CurrentImageChanged() while holding
* mReentrantMonitor.
*/
virtual already_AddRefed<Image> GetCurrentImage() = 0;
@ -186,8 +186,8 @@ public:
* Returns the size in aSize.
* The returned surface will never be modified. The caller must not
* modify it.
* Can be called on any thread. This method takes mMonitor when accessing
* thread-shared state.
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
*/
virtual already_AddRefed<gfxASurface> GetCurrentAsSurface(gfxIntSize* aSizeResult) = 0;
@ -204,7 +204,7 @@ public:
/**
* Returns the size of the image in pixels.
* Can be called on any thread. This method takes mMonitor when accessing
* Can be called on any thread. This method takes mReentrantMonitor when accessing
* thread-shared state.
*/
virtual gfxIntSize GetCurrentSize() = 0;
@ -220,8 +220,8 @@ public:
* Sets a size that the image is expected to be rendered at.
* This is a hint for image backends to optimize scaling.
* Default implementation in this class is to ignore the hint.
* Can be called on any thread. This method takes mMonitor when accessing
* thread-shared state.
* Can be called on any thread. This method takes mReentrantMonitor
* when accessing thread-shared state.
*/
virtual void SetScaleHint(const gfxIntSize& /* aScaleHint */) { }
@ -239,7 +239,7 @@ public:
* has not yet been painted. Can be called from any thread.
*/
TimeStamp GetPaintTime() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mPaintTime;
}
@ -248,7 +248,7 @@ public:
* and painted at least once. Can be called from any thread.
*/
PRUint32 GetPaintCount() {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return mPaintCount;
}
@ -258,7 +258,7 @@ public:
* current image. Can be called from any thread.
*/
void NotifyPaintedImage(Image* aPainted) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> current = GetCurrentImage();
if (aPainted == current) {
if (mPaintTime.IsNull()) {
@ -275,25 +275,25 @@ public:
}
protected:
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
LayerManager* mManager;
// Monitor to protect thread safe access to the "current image", and any
// other state which is shared between threads.
Monitor mMonitor;
// ReentrantMonitor to protect thread safe access to the "current
// image", and any other state which is shared between threads.
ReentrantMonitor mReentrantMonitor;
ImageContainer(LayerManager* aManager) :
mManager(aManager),
mMonitor("ImageContainer"),
mReentrantMonitor("ImageContainer.mReentrantMonitor"),
mPaintCount(0),
mPreviousImagePainted(PR_FALSE)
{}
// Performs necessary housekeeping to ensure the painted frame statistics
// are accurate. Must be called by SetCurrentImage() implementations with
// mMonitor held.
// mReentrantMonitor held.
void CurrentImageChanged() {
mMonitor.AssertCurrentThreadIn();
mReentrantMonitor.AssertCurrentThreadIn();
mPreviousImagePainted = !mPaintTime.IsNull();
mPaintTime = TimeStamp();
}

View File

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "ImageLayers.h"
#include "BasicLayers.h"
@ -52,7 +52,7 @@
#include "gfxPlatform.h"
using mozilla::Monitor;
using mozilla::ReentrantMonitor;
namespace mozilla {
namespace layers {
@ -326,7 +326,7 @@ BasicPlanarYCbCrImage::GetAsSurface()
/**
* Our image container is very simple. It's really just a factory
* for the image objects. We use a Monitor to synchronize access to
* for the image objects. We use a ReentrantMonitor to synchronize access to
* mImage.
*/
class BasicImageContainer : public ImageContainer {
@ -379,7 +379,7 @@ BasicImageContainer::CreateImage(const Image::Format* aFormats,
if (FormatInList(aFormats, aNumFormats, Image::CAIRO_SURFACE)) {
image = new BasicCairoImage();
} else if (FormatInList(aFormats, aNumFormats, Image::PLANAR_YCBCR)) {
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
image = new BasicPlanarYCbCrImage(mScaleHint);
static_cast<BasicPlanarYCbCrImage*>(image.get())->SetOffscreenFormat(mOffscreenFormat);
}
@ -389,7 +389,7 @@ BasicImageContainer::CreateImage(const Image::Format* aFormats,
void
BasicImageContainer::SetCurrentImage(Image* aImage)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mImage = aImage;
CurrentImageChanged();
}
@ -397,7 +397,7 @@ BasicImageContainer::SetCurrentImage(Image* aImage)
already_AddRefed<Image>
BasicImageContainer::GetCurrentImage()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> image = mImage;
return image.forget();
}
@ -413,7 +413,7 @@ BasicImageContainer::GetCurrentAsSurface(gfxIntSize* aSizeResult)
{
NS_PRECONDITION(NS_IsMainThread(), "Must be called on main thread");
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mImage) {
return nsnull;
}
@ -424,13 +424,13 @@ BasicImageContainer::GetCurrentAsSurface(gfxIntSize* aSizeResult)
gfxIntSize
BasicImageContainer::GetCurrentSize()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
return !mImage ? gfxIntSize(0,0) : ToImageData(mImage)->GetSize();
}
void BasicImageContainer::SetScaleHint(const gfxIntSize& aScaleHint)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mScaleHint = aScaleHint;
}

View File

@ -121,7 +121,7 @@ ImageContainerD3D10::CreateImage(const Image::Format *aFormats,
void
ImageContainerD3D10::SetCurrentImage(Image *aImage)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mActiveImage = aImage;
CurrentImageChanged();
@ -130,7 +130,7 @@ ImageContainerD3D10::SetCurrentImage(Image *aImage)
already_AddRefed<Image>
ImageContainerD3D10::GetCurrentImage()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> retval = mActiveImage;
return retval.forget();
@ -139,7 +139,7 @@ ImageContainerD3D10::GetCurrentImage()
already_AddRefed<gfxASurface>
ImageContainerD3D10::GetCurrentAsSurface(gfxIntSize *aSize)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
return nsnull;
}
@ -162,7 +162,7 @@ ImageContainerD3D10::GetCurrentAsSurface(gfxIntSize *aSize)
gfxIntSize
ImageContainerD3D10::GetCurrentSize()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
return gfxIntSize(0,0);
}

View File

@ -156,7 +156,7 @@ ImageContainerD3D9::CreateImage(const Image::Format *aFormats,
void
ImageContainerD3D9::SetCurrentImage(Image *aImage)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mActiveImage = aImage;
CurrentImageChanged();
@ -165,7 +165,7 @@ ImageContainerD3D9::SetCurrentImage(Image *aImage)
already_AddRefed<Image>
ImageContainerD3D9::GetCurrentImage()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> retval = mActiveImage;
return retval.forget();
@ -174,7 +174,7 @@ ImageContainerD3D9::GetCurrentImage()
already_AddRefed<gfxASurface>
ImageContainerD3D9::GetCurrentAsSurface(gfxIntSize *aSize)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
return nsnull;
}
@ -197,7 +197,7 @@ ImageContainerD3D9::GetCurrentAsSurface(gfxIntSize *aSize)
gfxIntSize
ImageContainerD3D9::GetCurrentSize()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
return gfxIntSize(0,0);
}

View File

@ -233,7 +233,7 @@ ImageContainerOGL::SetCurrentImage(Image *aImage)
nsRefPtr<Image> oldImage;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
oldImage = mActiveImage.forget();
mActiveImage = aImage;
@ -247,7 +247,7 @@ ImageContainerOGL::SetCurrentImage(Image *aImage)
already_AddRefed<Image>
ImageContainerOGL::GetCurrentImage()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsRefPtr<Image> retval = mActiveImage;
return retval.forget();
@ -256,7 +256,7 @@ ImageContainerOGL::GetCurrentImage()
already_AddRefed<gfxASurface>
ImageContainerOGL::GetCurrentAsSurface(gfxIntSize *aSize)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
*aSize = gfxIntSize(0,0);
@ -314,7 +314,7 @@ ImageContainerOGL::GetCurrentAsSurface(gfxIntSize *aSize)
gfxIntSize
ImageContainerOGL::GetCurrentSize()
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mActiveImage) {
return gfxIntSize(0,0);
}

View File

@ -87,7 +87,7 @@ nsStringBundle::nsStringBundle(const char* aURLSpec,
nsIStringBundleOverride* aOverrideStrings) :
mPropertiesURL(aURLSpec),
mOverrideStrings(aOverrideStrings),
mMonitor("nsStringBundle.mMonitor"),
mReentrantMonitor("nsStringBundle.mReentrantMonitor"),
mAttemptedLoad(PR_FALSE),
mLoaded(PR_FALSE)
{
@ -148,7 +148,7 @@ nsStringBundle::LoadProperties()
nsresult
nsStringBundle::GetStringFromID(PRInt32 aID, nsAString& aResult)
{
MonitorAutoEnter automon(mMonitor);
ReentrantMonitorAutoEnter automon(mReentrantMonitor);
nsCAutoString name;
name.AppendInt(aID, 10);
@ -269,7 +269,7 @@ nsStringBundle::GetStringFromName(const PRUnichar *aName, PRUnichar **aResult)
rv = LoadProperties();
if (NS_FAILED(rv)) return rv;
MonitorAutoEnter automon(mMonitor);
ReentrantMonitorAutoEnter automon(mReentrantMonitor);
*aResult = nsnull;
nsAutoString tmpstr;
rv = GetStringFromName(nsDependentString(aName), tmpstr);

View File

@ -38,7 +38,7 @@
#ifndef nsStringBundle_h__
#define nsStringBundle_h__
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIStringBundle.h"
#include "nsCOMPtr.h"
#include "nsIPersistentProperties2.h"
@ -71,7 +71,7 @@ protected:
private:
nsCString mPropertiesURL;
nsCOMPtr<nsIStringBundleOverride> mOverrideStrings;
mozilla::Monitor mMonitor;
mozilla::ReentrantMonitor mReentrantMonitor;
PRPackedBool mAttemptedLoad;
PRPackedBool mLoaded;

View File

@ -74,7 +74,7 @@
#include "APKOpen.h"
#endif
using mozilla::MonitorAutoEnter;
using mozilla::ReentrantMonitorAutoEnter;
using mozilla::ipc::GeckoChildProcessHost;
#ifdef ANDROID
@ -95,7 +95,7 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType,
base::WaitableEventWatcher::Delegate* aDelegate)
: ChildProcessHost(RENDER_PROCESS), // FIXME/cjones: we should own this enum
mProcessType(aProcessType),
mMonitor("mozilla.ipc.GeckChildProcessHost.mMonitor"),
mReentrantMonitor("mozilla.ipc.GeckChildProcessHost.mReentrantMonitor"),
mLaunched(false),
mChannelInitialized(false),
mDelegate(aDelegate),
@ -289,7 +289,7 @@ GeckoChildProcessHost::SyncLaunch(std::vector<std::string> aExtraOpts, int aTime
aExtraOpts, arch));
// NB: this uses a different mechanism than the chromium parent
// class.
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
PRIntervalTime waitStart = PR_IntervalNow();
PRIntervalTime current;
@ -327,7 +327,7 @@ GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts)
// This may look like the sync launch wait, but we only delay as
// long as it takes to create the channel.
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
while (!mChannelInitialized) {
mon.Wait();
}
@ -340,7 +340,7 @@ GeckoChildProcessHost::InitializeChannel()
{
CreateChannel();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mChannelInitialized = true;
mon.Notify();
}
@ -644,7 +644,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
void
GeckoChildProcessHost::OnChannelConnected(int32 peer_pid)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mLaunched = true;
if (!base::OpenPrivilegedProcessHandle(peer_pid, &mChildProcessHandle))

View File

@ -43,7 +43,7 @@
#include "base/waitable_event.h"
#include "chrome/common/child_process_host.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsXULAppAPI.h" // for GeckoProcessType
#include "nsString.h"
@ -54,7 +54,7 @@ namespace ipc {
class GeckoChildProcessHost : public ChildProcessHost
{
protected:
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
public:
typedef base::ProcessHandle ProcessHandle;
@ -106,7 +106,7 @@ public:
protected:
GeckoProcessType mProcessType;
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
bool mLaunched;
bool mChannelInitialized;
FilePath mProcessPath;

View File

@ -46,13 +46,10 @@
#include "nsStringGlue.h"
#include "nsIXULAppInfo.h"
#include "mozilla/Mutex.h"
#include "mozilla/PaintTracker.h"
using mozilla::ipc::SyncChannel;
using mozilla::ipc::RPCChannel;
using mozilla::MutexAutoUnlock;
using namespace mozilla;
using namespace mozilla::ipc;
using namespace mozilla::ipc::windows;
/**

View File

@ -97,7 +97,7 @@
#include "nsXPIDLString.h"
#include "nsAutoJSValHolder.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
#include "nsDataHashtable.h"
@ -335,7 +335,7 @@ typedef nsDataHashtable<xpc::PtrAndPrincipalHashKey, JSCompartment *> XPCCompart
#pragma warning(disable : 4355) // OK to pass "this" in member initializer
#endif
typedef mozilla::Monitor XPCLock;
typedef mozilla::ReentrantMonitor XPCLock;
static inline void xpc_Wait(XPCLock* lock)
{
@ -363,7 +363,7 @@ class NS_STACK_CLASS XPCAutoLock {
public:
static XPCLock* NewLock(const char* name)
{return new mozilla::Monitor(name);}
{return new mozilla::ReentrantMonitor(name);}
static void DestroyLock(XPCLock* lock)
{delete lock;}

View File

@ -45,6 +45,8 @@
#include <setjmp.h>
#include "jerror.h"
using namespace mozilla;
NS_IMPL_THREADSAFE_ISUPPORTS3(nsJPEGEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)
// used to pass error info through the JPEG library
@ -58,7 +60,7 @@ nsJPEGEncoder::nsJPEGEncoder() : mFinished(PR_FALSE),
mImageBufferUsed(0), mImageBufferReadPoint(0),
mCallback(nsnull),
mCallbackTarget(nsnull), mNotifyThreshold(0),
mMonitor("JPEG Encoder Monitor")
mReentrantMonitor("nsJPEGEncoder.mReentrantMonitor")
{
}
@ -268,7 +270,7 @@ NS_IMETHODIMP nsJPEGEncoder::Read(char * aBuf, PRUint32 aCount,
NS_IMETHODIMP nsJPEGEncoder::ReadSegments(nsWriteSegmentFun aWriter, void *aClosure, PRUint32 aCount, PRUint32 *_retval)
{
// Avoid another thread reallocing the buffer underneath us
mozilla::MonitorAutoEnter autoEnter(mMonitor);
ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
PRUint32 maxCount = mImageBufferUsed - mImageBufferReadPoint;
if (maxCount == 0) {
@ -415,7 +417,7 @@ nsJPEGEncoder::emptyOutputBuffer(jpeg_compress_struct* cinfo)
// When we're reallocing the buffer we need to take the lock to ensure
// that nobody is trying to read from the buffer we are destroying
mozilla::MonitorAutoEnter autoEnter(that->mMonitor);
ReentrantMonitorAutoEnter autoEnter(that->mReentrantMonitor);
that->mImageBufferUsed = that->mImageBufferSize;
@ -494,7 +496,7 @@ nsJPEGEncoder::NotifyListener()
// AsyncWait and any that do encoding) so we lock to avoid notifying the
// listener twice about the same data (which generally leads to a truncated
// image).
mozilla::MonitorAutoEnter autoEnter(mMonitor);
ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
if (mCallback &&
(mImageBufferUsed - mImageBufferReadPoint >= mNotifyThreshold ||

View File

@ -38,7 +38,7 @@
#include "imgIEncoder.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsCOMPtr.h"
@ -62,7 +62,7 @@ extern "C" {
class nsJPEGEncoder : public imgIEncoder
{
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGIENCODER
@ -107,5 +107,5 @@ protected:
we read from it (that it is not realloced) and to ensure that only one thread
dispatches a callback for each call to AsyncWait.
*/
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
};

View File

@ -46,6 +46,8 @@
#include "nsString.h"
#include "nsStreamUtils.h"
using namespace mozilla;
NS_IMPL_THREADSAFE_ISUPPORTS3(nsPNGEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)
nsPNGEncoder::nsPNGEncoder() : mPNG(nsnull), mPNGinfo(nsnull),
@ -55,7 +57,7 @@ nsPNGEncoder::nsPNGEncoder() : mPNG(nsnull), mPNGinfo(nsnull),
mImageBufferUsed(0), mImageBufferReadPoint(0),
mCallback(nsnull),
mCallbackTarget(nsnull), mNotifyThreshold(0),
mMonitor("PNG Encoder Monitor")
mReentrantMonitor("nsPNGEncoder.mReentrantMonitor")
{
}
@ -535,7 +537,7 @@ NS_IMETHODIMP nsPNGEncoder::ReadSegments(nsWriteSegmentFun aWriter,
PRUint32 *_retval)
{
// Avoid another thread reallocing the buffer underneath us
mozilla::MonitorAutoEnter autoEnter(mMonitor);
ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
PRUint32 maxCount = mImageBufferUsed - mImageBufferReadPoint;
if (maxCount == 0) {
@ -674,7 +676,7 @@ nsPNGEncoder::WriteCallback(png_structp png, png_bytep data,
if (that->mImageBufferUsed + size > that->mImageBufferSize) {
// When we're reallocing the buffer we need to take the lock to ensure
// that nobody is trying to read from the buffer we are destroying
mozilla::MonitorAutoEnter autoEnter(that->mMonitor);
ReentrantMonitorAutoEnter autoEnter(that->mReentrantMonitor);
// expand buffer, just double each time
that->mImageBufferSize *= 2;
@ -701,7 +703,7 @@ nsPNGEncoder::NotifyListener()
// AsyncWait and any that do encoding) so we lock to avoid notifying the
// listener twice about the same data (which generally leads to a truncated
// image).
mozilla::MonitorAutoEnter autoEnter(mMonitor);
ReentrantMonitorAutoEnter autoEnter(mReentrantMonitor);
if (mCallback &&
(mImageBufferUsed - mImageBufferReadPoint >= mNotifyThreshold ||

View File

@ -37,7 +37,7 @@
#include "imgIEncoder.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsCOMPtr.h"
@ -56,7 +56,7 @@
class nsPNGEncoder : public imgIEncoder
{
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
public:
NS_DECL_ISUPPORTS
NS_DECL_IMGIENCODER
@ -110,5 +110,5 @@ protected:
we read from it (that it is not realloced) and to ensure that only one thread
dispatches a callback for each call to AsyncWait.
*/
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
};

View File

@ -81,7 +81,7 @@ InsertTransactionSorted(nsTArray<nsHttpTransaction*> &pendingQ, nsHttpTransactio
nsHttpConnectionMgr::nsHttpConnectionMgr()
: mRef(0)
, mMonitor("nsHttpConnectionMgr.mMonitor")
, mReentrantMonitor("nsHttpConnectionMgr.mReentrantMonitor")
, mMaxConns(0)
, mMaxConnsPerHost(0)
, mMaxConnsPerProxy(0)
@ -115,7 +115,7 @@ nsHttpConnectionMgr::EnsureSocketThreadTargetIfOnline()
}
}
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// do nothing if already initialized or if we've shut down
if (mSocketThreadTarget || mIsShuttingDown)
@ -138,7 +138,7 @@ nsHttpConnectionMgr::Init(PRUint16 maxConns,
LOG(("nsHttpConnectionMgr::Init\n"));
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mMaxConns = maxConns;
mMaxConnsPerHost = maxConnsPerHost;
@ -159,7 +159,7 @@ nsHttpConnectionMgr::Shutdown()
{
LOG(("nsHttpConnectionMgr::Shutdown\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// do nothing if already shutdown
if (!mSocketThreadTarget)
@ -192,7 +192,7 @@ nsHttpConnectionMgr::PostEvent(nsConnEventHandler handler, PRInt32 iparam, void
// care of initializing the socket thread target if that's the case.
EnsureSocketThreadTargetIfOnline();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
nsresult rv;
if (!mSocketThreadTarget) {
@ -317,7 +317,7 @@ nsHttpConnectionMgr::GetSocketThreadTarget(nsIEventTarget **target)
// care of initializing the socket thread target if that's the case.
EnsureSocketThreadTargetIfOnline();
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
NS_IF_ADDREF(*target = mSocketThreadTarget);
return NS_OK;
}
@ -920,7 +920,7 @@ nsHttpConnectionMgr::OnMsgShutdown(PRInt32, void *)
mCT.Reset(ShutdownPassCB, this);
// signal shutdown complete
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Notify();
}

View File

@ -46,7 +46,7 @@
#include "nsThreadUtils.h"
#include "nsHashtable.h"
#include "nsAutoPtr.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsISocketTransportService.h"
#include "nsIObserver.h"
@ -228,11 +228,11 @@ private:
friend class nsHalfOpenSocket;
//-------------------------------------------------------------------------
// NOTE: these members may be accessed from any thread (use mMonitor)
// NOTE: these members may be accessed from any thread (use mReentrantMonitor)
//-------------------------------------------------------------------------
PRInt32 mRef;
mozilla::Monitor mMonitor;
mozilla::ReentrantMonitor mReentrantMonitor;
nsCOMPtr<nsIEventTarget> mSocketThreadTarget;
// connection limits

View File

@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsMaemoNetworkManager.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
@ -70,7 +70,7 @@ static PRBool gConnectionCallbackInvoked = PR_FALSE;
using namespace mozilla;
static Monitor* gMonitor = nsnull;
static ReentrantMonitor* gReentrantMonitor = nsnull;
static void NotifyNetworkLinkObservers()
{
@ -88,7 +88,7 @@ connection_event_callback(ConIcConnection *aConnection,
{
ConIcConnectionStatus status = con_ic_connection_event_get_status(aEvent);
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
// When we are not connected, we are always disconnected.
gInternalState = (CON_IC_STATUS_CONNECTED == status ?
@ -110,7 +110,7 @@ nsMaemoNetworkManager::OpenConnectionSync()
// protect gInternalState. This also allows us
// to block and wait in this method on this thread
// until our callback on the main thread.
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
gConnectionCallbackInvoked = PR_FALSE;
@ -153,8 +153,8 @@ nsMaemoNetworkManager::Startup()
if (gConnection)
return PR_TRUE;
gMonitor = new Monitor("MaemoAutodialer");
if (!gMonitor)
gReentrantMonitor = new ReentrantMonitor("MaemoAutodialer");
if (!gReentrantMonitor)
return PR_FALSE;
DBusError error;
@ -169,8 +169,8 @@ nsMaemoNetworkManager::Startup()
gConnection = con_ic_connection_new();
NS_ASSERTION(gConnection, "Error when creating connection");
if (!gConnection) {
delete gMonitor;
gMonitor = nsnull;
delete gReentrantMonitor;
gReentrantMonitor = nsnull;
return PR_FALSE;
}
@ -191,14 +191,14 @@ nsMaemoNetworkManager::Shutdown()
{
gConnection = nsnull;
if (gMonitor) {
if (gReentrantMonitor) {
// notify anyone waiting
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
gInternalState = InternalState_Invalid;
mon.Notify();
}
// We are leaking the gMonitor because a race condition could occur. We need
// We are leaking the gReentrantMonitor because a race condition could occur. We need
// a notification after xpcom-shutdown-threads so we can safely delete the monitor
}

View File

@ -65,7 +65,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS3(nsWifiMonitor,
nsWifiMonitor::nsWifiMonitor()
: mKeepGoing(PR_TRUE)
, mMonitor("nsWifiMonitor.mMonitor")
, mReentrantMonitor("nsWifiMonitor.mReentrantMonitor")
{
#if defined(PR_LOGGING)
gWifiMonitorLog = PR_NewLogModule("WifiMonitor");
@ -90,7 +90,7 @@ nsWifiMonitor::Observe(nsISupports *subject, const char *topic,
LOG(("Shutting down\n"));
mKeepGoing = PR_FALSE;
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Notify();
}
return NS_OK;
@ -109,7 +109,7 @@ NS_IMETHODIMP nsWifiMonitor::StartWatching(nsIWifiListener *aListener)
return rv;
}
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mKeepGoing = PR_TRUE;
@ -127,7 +127,7 @@ NS_IMETHODIMP nsWifiMonitor::StopWatching(nsIWifiListener *aListener)
LOG(("removing listener\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 i = 0; i < mListeners.Length(); i++) {

View File

@ -44,7 +44,7 @@
#include "nsIRunnable.h"
#include "nsCOMArray.h"
#include "nsIWifiMonitor.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "prlog.h"
#include "nsIObserver.h"
#include "nsTArray.h"
@ -97,7 +97,7 @@ class nsWifiMonitor : nsIRunnable, nsIWifiMonitor, nsIObserver
nsTArray<nsWifiListener> mListeners;
mozilla::Monitor mMonitor;
mozilla::ReentrantMonitor mReentrantMonitor;
};

View File

@ -77,7 +77,7 @@ nsWifiMonitor::DoScanWithCoreWLAN()
nsCOMArray<nsIWifiListener> currentListeners;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
if (!mListeners[i].mHasSentData || accessPointsChanged) {
@ -127,7 +127,7 @@ nsWifiMonitor::DoScanWithCoreWLAN()
// wait for some reasonable amount of time. pref?
LOG(("waiting on monitor\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Wait(PR_SecondsToInterval(60));
}
while (mKeepGoing);
@ -212,7 +212,7 @@ nsWifiMonitor::DoScanOld()
nsCOMArray<nsIWifiListener> currentListeners;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
if (!mListeners[i].mHasSentData || accessPointsChanged) {
@ -263,7 +263,7 @@ nsWifiMonitor::DoScanOld()
// wait for some reasonable amount of time. pref?
LOG(("waiting on monitor\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Wait(PR_SecondsToInterval(60));
}
while (mKeepGoing);

View File

@ -170,7 +170,7 @@ nsWifiMonitor::DoScan()
nsCOMArray<nsIWifiListener> currentListeners;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
if (!mListeners[i].mHasSentData || accessPointsChanged) {
@ -220,7 +220,7 @@ nsWifiMonitor::DoScan()
LOG(("waiting on monitor\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Wait(PR_SecondsToInterval(60));
}

View File

@ -154,7 +154,7 @@ nsWifiMonitor::DoScan()
nsCOMArray<nsIWifiListener> currentListeners;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
for (PRUint32 i = 0; i < mListeners.Length(); i++) {
if (!mListeners[i].mHasSentData || accessPointsChanged) {
@ -202,7 +202,7 @@ nsWifiMonitor::DoScan()
// wait for some reasonable amount of time. pref?
LOG(("waiting on monitor\n"));
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mon.Wait(PR_SecondsToInterval(60));
}
while (mKeepGoing);

View File

@ -160,7 +160,7 @@ class nsAutoAtomic {
#endif
nsSecureBrowserUIImpl::nsSecureBrowserUIImpl()
: mMonitor("nsSecureBrowserUIImpl.mMonitor")
: mReentrantMonitor("nsSecureBrowserUIImpl.mReentrantMonitor")
, mNotifiedSecurityState(lis_no_security)
, mNotifiedToplevelIsEV(PR_FALSE)
, mNewToplevelSecurityState(STATE_IS_INSECURE)
@ -277,7 +277,7 @@ nsSecureBrowserUIImpl::Init(nsIDOMWindow *aWindow)
NS_IMETHODIMP
nsSecureBrowserUIImpl::GetState(PRUint32* aState)
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
return MapInternalToExternalState(aState, mNotifiedSecurityState, mNotifiedToplevelIsEV);
}
@ -341,7 +341,7 @@ nsSecureBrowserUIImpl::GetTooltipText(nsAString& aText)
nsXPIDLString tooltip;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
state = mNotifiedSecurityState;
tooltip = mInfoTooltip;
}
@ -460,7 +460,7 @@ nsSecureBrowserUIImpl::Notify(nsIDOMHTMLFormElement* aDOMForm,
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -496,7 +496,7 @@ nsSecureBrowserUIImpl::OnProgressChange(nsIWebProgress* aWebProgress,
void nsSecureBrowserUIImpl::ResetStateTracking()
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
mInfoTooltip.Truncate();
mDocumentRequestsInProgress = 0;
@ -558,7 +558,7 @@ nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest* aRequest, nsIS
// see code that is directly above
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
mNewToplevelSecurityStateKnown = PR_TRUE;
mNewToplevelSecurityState = temp_NewToplevelSecurityState;
mNewToplevelIsEV = temp_NewToplevelIsEV;
@ -591,7 +591,7 @@ nsSecureBrowserUIImpl::UpdateSubrequestMembers(nsISupports *securityInfo)
PRUint32 reqState = GetSecurityStateFromSecurityInfo(securityInfo);
// the code above this line should run without a lock
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
if (reqState & STATE_IS_SECURE) {
if (reqState & STATE_SECURE_LOW || reqState & STATE_SECURE_MED) {
@ -724,7 +724,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
nsCOMPtr<nsINetUtil> ioService;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
isViewSource = mIsViewSource;
@ -736,7 +736,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
ioService = do_GetService(NS_IOSERVICE_CONTRACTID);
if (ioService)
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
mIOService = ioService;
}
}
@ -1013,7 +1013,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
// The listing of a request in mTransferringRequests
// means, there has already been data transfered.
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
PL_DHashTableOperate(&mTransferringRequests, aRequest, PL_DHASH_ADD);
return NS_OK;
@ -1025,8 +1025,8 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
&&
aProgressStateFlags & STATE_IS_REQUEST)
{
{ /* scope for the MonitorAutoEnter */
MonitorAutoEnter lock(mMonitor);
{ /* scope for the ReentrantMonitorAutoEnter */
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
PLDHashEntryHdr *entry = PL_DHashTableOperate(&mTransferringRequests, aRequest, PL_DHASH_LOOKUP);
if (PL_DHASH_ENTRY_IS_BUSY(entry))
{
@ -1084,7 +1084,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
PRInt32 newSubNo = 0;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
inProgress = (mDocumentRequestsInProgress!=0);
if (allowSecurityStateChange && !inProgress)
@ -1154,7 +1154,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
}
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
if (allowSecurityStateChange && !inProgress)
{
@ -1190,7 +1190,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
nsCOMPtr<nsISecurityEventSink> temp_ToplevelEventSink;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
temp_DocumentRequestsInProgress = mDocumentRequestsInProgress;
if (allowSecurityStateChange)
{
@ -1218,7 +1218,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
}
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
if (allowSecurityStateChange)
{
mToplevelEventSink = temp_ToplevelEventSink;
@ -1263,7 +1263,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
PRBool temp_NewToplevelSecurityStateKnown;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown;
}
@ -1309,7 +1309,7 @@ nsresult nsSecureBrowserUIImpl::UpdateSecurityState(nsIRequest* aRequest,
// returns true if our overall state has changed and we must send out notifications
PRBool nsSecureBrowserUIImpl::UpdateMyFlags(PRBool &showWarning, lockIconState &warnSecurityState)
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
PRBool mustTellTheWorld = PR_FALSE;
lockIconState newSecurityState;
@ -1459,7 +1459,7 @@ nsresult nsSecureBrowserUIImpl::TellTheWorld(PRBool showWarning,
PRBool temp_NotifiedToplevelIsEV;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
temp_ToplevelEventSink = mToplevelEventSink;
temp_NotifiedSecurityState = mNotifiedSecurityState;
temp_NotifiedToplevelIsEV = mNotifiedToplevelIsEV;
@ -1546,7 +1546,7 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
}
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
if (updateIsViewSource) {
mIsViewSource = temp_IsViewSource;
}
@ -1594,7 +1594,7 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
PRBool temp_NewToplevelSecurityStateKnown;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
temp_NewToplevelSecurityStateKnown = mNewToplevelSecurityStateKnown;
}
@ -1645,7 +1645,7 @@ nsSecureBrowserUIImpl::GetSSLStatus(nsISupports** _result)
{
NS_ENSURE_ARG_POINTER(_result);
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
switch (mNotifiedSecurityState)
{
@ -1697,7 +1697,7 @@ nsSecureBrowserUIImpl::GetBundleString(const PRUnichar* name,
nsCOMPtr<nsIStringBundle> temp_StringBundle;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
temp_StringBundle = mStringBundle;
}
@ -1841,7 +1841,7 @@ ConfirmEnteringSecure()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -1864,7 +1864,7 @@ ConfirmEnteringWeak()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -1887,7 +1887,7 @@ ConfirmLeavingSecure()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -1910,7 +1910,7 @@ ConfirmMixedMode()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -1940,7 +1940,7 @@ ConfirmPostToInsecure()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}
@ -1972,7 +1972,7 @@ ConfirmPostToInsecureFromSecure()
nsCOMPtr<nsIDOMWindow> window;
{
MonitorAutoEnter lock(mMonitor);
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
window = do_QueryReferent(mWindow);
NS_ASSERTION(window, "Window has gone away?!");
}

View File

@ -42,7 +42,7 @@
#ifndef nsSecureBrowserUIImpl_h_
#define nsSecureBrowserUIImpl_h_
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsString.h"
@ -97,7 +97,7 @@ public:
nsIArray* invalidElements) { return NS_OK; };
protected:
mozilla::Monitor mMonitor;
mozilla::ReentrantMonitor mReentrantMonitor;
nsWeakPtr mWindow;
nsCOMPtr<nsINetUtil> mIOService;
@ -129,7 +129,7 @@ protected:
PRInt32 mSubRequestsBrokenSecurity;
PRInt32 mSubRequestsNoSecurity;
#ifdef DEBUG
/* related to mMonitor */
/* related to mReentrantMonitor */
PRInt32 mOnStateLocationChangeReentranceDetection;
#endif

View File

@ -179,7 +179,7 @@ nsCertOverrideService::Observe(nsISupports *aSubject,
// The profile is about to change,
// or is going away because the application is shutting down.
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
if (!nsCRT::strcmp(aData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
RemoveAllFromMemory();
@ -196,7 +196,7 @@ nsCertOverrideService::Observe(nsISupports *aSubject,
// Now read from the new profile location.
// we also need to update the cached file location
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(mSettingsFile));
if (NS_SUCCEEDED(rv)) {
@ -212,7 +212,7 @@ nsCertOverrideService::Observe(nsISupports *aSubject,
void
nsCertOverrideService::RemoveAllFromMemory()
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.Clear();
}
@ -232,7 +232,7 @@ void
nsCertOverrideService::RemoveAllTemporaryOverrides()
{
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.EnumerateEntries(RemoveTemporariesCallback, nsnull);
// no need to write, as temporaries are never written to disk
}
@ -241,7 +241,7 @@ nsCertOverrideService::RemoveAllTemporaryOverrides()
nsresult
nsCertOverrideService::Read()
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsresult rv;
nsCOMPtr<nsIInputStream> fileInputStream;
@ -360,7 +360,7 @@ WriteEntryCallback(nsCertOverrideEntry *aEntry,
nsresult
nsCertOverrideService::Write()
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
if (!mSettingsFile) {
return NS_ERROR_NULL_POINTER;
@ -554,7 +554,7 @@ nsCertOverrideService::RememberValidityOverride(const nsACString & aHostName, PR
}
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
AddEntryToList(aHostName, aPort,
aTemporary ? aCert : nsnull,
// keep a reference to the cert for temporary overrides
@ -593,7 +593,7 @@ nsCertOverrideService::HasMatchingOverride(const nsACString & aHostName, PRInt32
nsCertOverride settings;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsCertOverrideEntry *entry = mSettingsTable.GetEntry(hostPort.get());
if (!entry)
@ -640,7 +640,7 @@ nsCertOverrideService::GetValidityOverride(const nsACString & aHostName, PRInt32
nsCertOverride settings;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsCertOverrideEntry *entry = mSettingsTable.GetEntry(hostPort.get());
if (entry) {
@ -672,7 +672,7 @@ nsCertOverrideService::AddEntryToList(const nsACString &aHostName, PRInt32 aPort
GetHostWithPort(aHostName, aPort, hostPort);
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsCertOverrideEntry *entry = mSettingsTable.PutEntry(hostPort.get());
if (!entry) {
@ -707,7 +707,7 @@ nsCertOverrideService::ClearValidityOverride(const nsACString & aHostName, PRInt
nsCAutoString hostPort;
GetHostWithPort(aHostName, aPort, hostPort);
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.RemoveEntry(hostPort.get());
Write();
}
@ -837,7 +837,7 @@ nsCertOverrideService::IsCertUsedForOverrides(nsIX509Cert *aCert,
cai.mDottedOidForStoringNewHashes = mDottedOidForStoringNewHashes;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.EnumerateEntries(FindMatchingCertCallback, &cai);
}
*_retval = cai.counter;
@ -903,7 +903,7 @@ nsCertOverrideService::EnumerateCertOverrides(nsIX509Cert *aCert,
capac.mDottedOidForStoringNewHashes = mDottedOidForStoringNewHashes;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.EnumerateEntries(EnumerateCertOverridesCallback, &capac);
}
return NS_OK;

View File

@ -41,7 +41,7 @@
#ifndef __NSCERTOVERRIDESERVICE_H__
#define __NSCERTOVERRIDESERVICE_H__
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsICertOverrideService.h"
#include "nsTHashtable.h"
#include "nsIObserver.h"
@ -190,7 +190,7 @@ public:
static void GetHostWithPort(const nsACString & aHostName, PRInt32 aPort, nsACString& _retval);
protected:
mozilla::Monitor monitor;
mozilla::ReentrantMonitor monitor;
nsCOMPtr<nsIFile> mSettingsFile;
nsTHashtable<nsCertOverrideEntry> mSettingsTable;

View File

@ -110,7 +110,7 @@ nsClientAuthRememberService::Observe(nsISupports *aSubject,
// The profile is about to change,
// or is going away because the application is shutting down.
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
RemoveAllFromMemory();
}
@ -119,7 +119,7 @@ nsClientAuthRememberService::Observe(nsISupports *aSubject,
void nsClientAuthRememberService::ClearRememberedDecisions()
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
RemoveAllFromMemory();
}
@ -165,7 +165,7 @@ nsClientAuthRememberService::RememberDecision(const nsACString & aHostName,
return rv;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
if (aClientCert) {
nsNSSCertificate pipCert(aClientCert);
char *dbkey = NULL;
@ -211,7 +211,7 @@ nsClientAuthRememberService::HasRememberedDecision(const nsACString & aHostName,
nsClientAuthRemember settings;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsClientAuthRememberEntry *entry = mSettingsTable.GetEntry(hostCert.get());
if (!entry)
return NS_OK;
@ -233,7 +233,7 @@ nsClientAuthRememberService::AddEntryToList(const nsACString &aHostName,
GetHostWithCert(aHostName, fingerprint, hostCert);
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
nsClientAuthRememberEntry *entry = mSettingsTable.PutEntry(hostCert.get());
if (!entry) {

View File

@ -40,7 +40,7 @@
#ifndef __NSCLIENTAUTHREMEMBER_H__
#define __NSCLIENTAUTHREMEMBER_H__
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsTHashtable.h"
#include "nsIObserver.h"
#include "nsIX509Cert.h"
@ -163,7 +163,7 @@ public:
void ClearRememberedDecisions();
protected:
mozilla::Monitor monitor;
mozilla::ReentrantMonitor monitor;
nsTHashtable<nsClientAuthRememberEntry> mSettingsTable;
void RemoveAllFromMemory();

View File

@ -99,7 +99,7 @@ nsRecentBadCertsService::GetRecentBadCert(const nsAString & aHostNameWithPort,
PRBool isUntrusted = PR_FALSE;
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
for (size_t i=0; i<const_recently_seen_list_size; ++i) {
if (mCerts[i].mHostWithPort.Equals(aHostNameWithPort)) {
SECStatus srv = SECITEM_CopyItem(nsnull, &foundDER, &mCerts[i].mDERCert);
@ -172,7 +172,7 @@ nsRecentBadCertsService::AddBadCert(const nsAString &hostWithPort,
NS_ENSURE_SUCCESS(rv, rv);
{
MonitorAutoEnter lock(monitor);
ReentrantMonitorAutoEnter lock(monitor);
RecentBadCert &updatedEntry = mCerts[mNextStorePosition];
++mNextStorePosition;

View File

@ -40,7 +40,7 @@
#ifndef __RECENTBADCERTS_H__
#define __RECENTBADCERTS_H__
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIRecentBadCertsService.h"
#include "nsTHashtable.h"
#include "nsString.h"
@ -105,7 +105,7 @@ public:
nsresult Init();
protected:
mozilla::Monitor monitor;
mozilla::ReentrantMonitor monitor;
enum {const_recently_seen_list_size = 5};
RecentBadCert mCerts[const_recently_seen_list_size];

View File

@ -50,7 +50,7 @@
#include "nsMemory.h"
#include "mozilla/CondVar.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "SQLiteMutex.h"
#include "TestHarness.h"
@ -431,7 +431,7 @@ Sanity3()
nsresult
Sanity4_Child()
{
mozilla::Monitor m1("dd.sanity4.m1");
mozilla::ReentrantMonitor m1("dd.sanity4.m1");
TestMutex m2("dd.sanity4.m2");
m1.Enter();
m2.Lock();
@ -443,11 +443,11 @@ nsresult
Sanity4()
{
const char* const tokens[] = {
"Re-entering Monitor after acquiring other resources",
"Re-entering ReentrantMonitor after acquiring other resources",
"###!!! ERROR: Potential deadlock detected",
"=== Cyclical dependency starts at\n--- Monitor : dd.sanity4.m1",
"=== Cyclical dependency starts at\n--- ReentrantMonitor : dd.sanity4.m1",
"--- Next dependency:\n--- Mutex : dd.sanity4.m2",
"=== Cycle completed at\n--- Monitor : dd.sanity4.m1",
"=== Cycle completed at\n--- ReentrantMonitor : dd.sanity4.m1",
"###!!! ASSERTION: Potential deadlock detected",
0
};

View File

@ -39,7 +39,6 @@
#include "storage_test_harness.h"
#include "mozilla/Monitor.h"
#include "nsThreadUtils.h"
/**

View File

@ -43,10 +43,10 @@
#include "sqlite3.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
using mozilla::Monitor;
using mozilla::MonitorAutoEnter;
using mozilla::ReentrantMonitor;
using mozilla::ReentrantMonitorAutoEnter;
/**
* Verify that mozIStorageAsyncStatement's life-cycle never triggers a mutex on
@ -140,7 +140,7 @@ class ThreadWedger : public nsRunnable
{
public:
ThreadWedger(nsIEventTarget *aTarget)
: mMonitor("thread wedger")
: mReentrantMonitor("thread wedger")
, unwedged(false)
{
aTarget->Dispatch(this, aTarget->NS_DISPATCH_NORMAL);
@ -148,7 +148,7 @@ public:
NS_IMETHOD Run()
{
MonitorAutoEnter automon(mMonitor);
ReentrantMonitorAutoEnter automon(mReentrantMonitor);
if (!unwedged)
automon.Wait();
@ -158,13 +158,13 @@ public:
void unwedge()
{
MonitorAutoEnter automon(mMonitor);
ReentrantMonitorAutoEnter automon(mReentrantMonitor);
unwedged = true;
automon.Notify();
}
private:
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
bool unwedged;
};

View File

@ -39,7 +39,7 @@
#include "storage_test_harness.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsThreadUtils.h"
#include "mozIStorageStatement.h"
@ -78,7 +78,7 @@ public:
NS_IMETHOD Run()
{
mozilla::MonitorAutoEnter lock(monitor);
mozilla::ReentrantMonitorAutoEnter lock(monitor);
nsCOMPtr<mozIStorageConnection> db(getDatabase());
@ -110,7 +110,7 @@ public:
do_check_success(monitor.Notify());
}
mozilla::Monitor monitor;
mozilla::ReentrantMonitor monitor;
protected:
nsCOMPtr<nsIThread> mThread;
@ -130,7 +130,7 @@ public:
NS_IMETHOD Run()
{
mozilla::MonitorAutoEnter lock(monitor);
mozilla::ReentrantMonitorAutoEnter lock(monitor);
WaitFor(READ_LOCK);
nsCString sql(mSQL);
@ -199,7 +199,7 @@ test_step_locked_does_not_block_main_thread()
nsRefPtr<DatabaseLocker> locker(new DatabaseLocker("SELECT * FROM test"));
do_check_true(locker);
mozilla::MonitorAutoEnter lock(locker->monitor);
mozilla::ReentrantMonitorAutoEnter lock(locker->monitor);
locker->RunInBackground();
// Wait for the locker to notify us that it has locked the database properly.
@ -228,7 +228,7 @@ test_drop_index_does_not_loop()
nsRefPtr<DatabaseTester> tester =
new DatabaseTester(db, "DROP INDEX unique_data");
do_check_true(tester);
mozilla::MonitorAutoEnter lock(tester->monitor);
mozilla::ReentrantMonitorAutoEnter lock(tester->monitor);
tester->RunInBackground();
// Hold a read lock on the database, and then let the tester try to execute.
@ -257,7 +257,7 @@ test_drop_table_does_not_loop()
nsRefPtr<DatabaseTester> tester(new DatabaseTester(db, "DROP TABLE test"));
do_check_true(tester);
mozilla::MonitorAutoEnter lock(tester->monitor);
mozilla::ReentrantMonitorAutoEnter lock(tester->monitor);
tester->RunInBackground();
// Hold a read lock on the database, and then let the tester try to execute.

View File

@ -427,7 +427,7 @@ void
nsComponentManagerImpl::RegisterModule(const mozilla::Module* aModule,
nsILocalFile* aFile)
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
KnownModule* m = new KnownModule(aModule, aFile);
if (aFile) {
@ -794,7 +794,7 @@ nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& cx, int lin
return;
}
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* f = mFactories.Get(cid);
if (f) {
char idstr[NSID_LENGTH];
@ -879,7 +879,7 @@ nsComponentManagerImpl::ManifestContract(ManifestProcessingContext& cx, int line
return;
}
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* f = mFactories.Get(cid);
if (!f) {
LogMessageWithContext(cx.mFile, cx.mPath, lineno,
@ -1056,7 +1056,7 @@ nsFactoryEntry *
nsComponentManagerImpl::GetFactoryEntry(const char *aContractID,
PRUint32 aContractIDLen)
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
return mContractIDs.Get(nsDependentCString(aContractID, aContractIDLen));
}
@ -1064,7 +1064,7 @@ nsComponentManagerImpl::GetFactoryEntry(const char *aContractID,
nsFactoryEntry *
nsComponentManagerImpl::GetFactoryEntry(const nsCID &aClass)
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
return mFactories.Get(aClass);
}
@ -1381,24 +1381,24 @@ nsComponentManagerImpl::GetPendingServiceThread(const nsCID& aServiceCID) const
}
// GetService() wants to manually Exit()/Enter() a monitor which is
// wrapped in MonitorAutoEnter, which nsAutoMonitor used to allow.
// wrapped in ReentrantMonitorAutoEnter, which nsAutoReentrantMonitor used to allow.
// One use is block-scoped Exit()/Enter(), which could be supported
// with something like a MonitoAutoExit, but that's not a well-defined
// operation in general so that helper doesn't exist. The other use
// is early-Exit() for perf reasons. This code is probably hot enough
// to warrant special considerations.
//
// We could use bare mozilla::Monitor, but that's error prone.
// We could use bare mozilla::ReentrantMonitor, but that's error prone.
// Instead, we just add a hacky wrapper here that acts like the old
// nsAutoMonitor.
struct NS_STACK_CLASS AutoMonitor
// nsAutoReentrantMonitor.
struct NS_STACK_CLASS AutoReentrantMonitor
{
AutoMonitor(Monitor& aMonitor) : mMonitor(&aMonitor), mEnterCount(0)
AutoReentrantMonitor(ReentrantMonitor& aReentrantMonitor) : mReentrantMonitor(&aReentrantMonitor), mEnterCount(0)
{
Enter();
}
~AutoMonitor()
~AutoReentrantMonitor()
{
if (mEnterCount) {
Exit();
@ -1407,17 +1407,17 @@ struct NS_STACK_CLASS AutoMonitor
void Enter()
{
mMonitor->Enter();
mReentrantMonitor->Enter();
++mEnterCount;
}
void Exit()
{
--mEnterCount;
mMonitor->Exit();
mReentrantMonitor->Exit();
}
Monitor* mMonitor;
ReentrantMonitor* mReentrantMonitor;
PRInt32 mEnterCount;
};
@ -1441,7 +1441,7 @@ nsComponentManagerImpl::GetService(const nsCID& aClass,
return NS_ERROR_UNEXPECTED;
}
AutoMonitor mon(mMon);
AutoReentrantMonitor mon(mMon);
nsFactoryEntry* entry = mFactories.Get(aClass);
if (!entry)
@ -1560,7 +1560,7 @@ nsComponentManagerImpl::IsServiceInstantiated(const nsCID & aClass,
nsFactoryEntry* entry;
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
entry = mFactories.Get(aClass);
}
@ -1599,7 +1599,7 @@ NS_IMETHODIMP nsComponentManagerImpl::IsServiceInstantiatedByContractID(const ch
nsresult rv = NS_ERROR_SERVICE_NOT_AVAILABLE;
nsFactoryEntry *entry;
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
entry = mContractIDs.Get(nsDependentCString(aContractID));
}
@ -1631,7 +1631,7 @@ nsComponentManagerImpl::GetServiceByContractID(const char* aContractID,
return NS_ERROR_UNEXPECTED;
}
AutoMonitor mon(mMon);
AutoReentrantMonitor mon(mMon);
nsFactoryEntry *entry = mContractIDs.Get(nsDependentCString(aContractID));
if (!entry)
@ -1751,7 +1751,7 @@ nsComponentManagerImpl::RegisterFactory(const nsCID& aClass,
if (!aContractID)
return NS_ERROR_INVALID_ARG;
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* oldf = mFactories.Get(aClass);
if (!oldf)
return NS_ERROR_FACTORY_NOT_REGISTERED;
@ -1762,7 +1762,7 @@ nsComponentManagerImpl::RegisterFactory(const nsCID& aClass,
nsAutoPtr<nsFactoryEntry> f(new nsFactoryEntry(aClass, aFactory));
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* oldf = mFactories.Get(aClass);
if (oldf)
return NS_ERROR_FACTORY_EXISTS;
@ -1785,7 +1785,7 @@ nsComponentManagerImpl::UnregisterFactory(const nsCID& aClass,
nsCOMPtr<nsISupports> dyingServiceObject;
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* f = mFactories.Get(aClass);
if (!f || f->mFactory != aFactory)
return NS_ERROR_FACTORY_NOT_REGISTERED;
@ -1920,7 +1920,7 @@ nsComponentManagerImpl::ContractIDToCID(const char *aContractID,
nsCID * *_retval)
{
{
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
nsFactoryEntry* entry = mContractIDs.Get(nsDependentCString(aContractID));
if (entry) {
*_retval = (nsCID*) NS_Alloc(sizeof(nsCID));

View File

@ -47,7 +47,7 @@
#include "nsILocalFile.h"
#include "mozilla/Module.h"
#include "mozilla/ModuleLoader.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsXULAppAPI.h"
#include "nsNativeComponentLoader.h"
#include "nsIFactory.h"
@ -150,7 +150,7 @@ public:
nsDataHashtable<nsIDHashKey, nsFactoryEntry*> mFactories;
nsDataHashtable<nsCStringHashKey, nsFactoryEntry*> mContractIDs;
mozilla::Monitor mMon;
mozilla::ReentrantMonitor mMon;
static void InitializeStaticModules();
static void InitializeModuleLocations();

View File

@ -43,7 +43,7 @@
#include "nsAutoPtr.h"
#include "mozilla/CondVar.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
#endif // ifdef DEBUG
@ -56,7 +56,7 @@ namespace mozilla {
const char* const BlockingResourceBase::kResourceTypeName[] =
{
// needs to be kept in sync with BlockingResourceType
"Mutex", "Monitor", "CondVar"
"Mutex", "ReentrantMonitor", "CondVar"
};
#ifdef DEBUG
@ -272,9 +272,9 @@ Mutex::Unlock()
//
// Debug implementation of Monitor
// Debug implementation of ReentrantMonitor
void
Monitor::Enter()
ReentrantMonitor::Enter()
{
BlockingResourceBase* chainFront = ResourceChainFront();
@ -282,7 +282,7 @@ Monitor::Enter()
if (this == chainFront) {
// immediately re-entered the monitor: acceptable
PR_EnterMonitor(mMonitor);
PR_EnterMonitor(mReentrantMonitor);
++mEntryCount;
return;
}
@ -297,14 +297,14 @@ Monitor::Enter()
br = ResourceChainPrev(br)) {
if (br == this) {
NS_WARNING(
"Re-entering Monitor after acquiring other resources.\n"
"Re-entering ReentrantMonitor after acquiring other resources.\n"
"At calling context\n");
GetAcquisitionContext().Print(stderr);
// show the caller why this is potentially bad
CheckAcquire(callContext);
PR_EnterMonitor(mMonitor);
PR_EnterMonitor(mReentrantMonitor);
++mEntryCount;
return;
}
@ -312,23 +312,23 @@ Monitor::Enter()
}
CheckAcquire(callContext);
PR_EnterMonitor(mMonitor);
NS_ASSERTION(0 == mEntryCount, "Monitor isn't free!");
Acquire(callContext); // protected by mMonitor
PR_EnterMonitor(mReentrantMonitor);
NS_ASSERTION(0 == mEntryCount, "ReentrantMonitor isn't free!");
Acquire(callContext); // protected by mReentrantMonitor
mEntryCount = 1;
}
void
Monitor::Exit()
ReentrantMonitor::Exit()
{
if (0 == --mEntryCount)
Release(); // protected by mMonitor
PRStatus status = PR_ExitMonitor(mMonitor);
NS_ASSERTION(PR_SUCCESS == status, "bad Monitor::Exit()");
Release(); // protected by mReentrantMonitor
PRStatus status = PR_ExitMonitor(mReentrantMonitor);
NS_ASSERTION(PR_SUCCESS == status, "bad ReentrantMonitor::Exit()");
}
nsresult
Monitor::Wait(PRIntervalTime interval)
ReentrantMonitor::Wait(PRIntervalTime interval)
{
AssertCurrentThreadIn();
@ -342,7 +342,7 @@ Monitor::Wait(PRIntervalTime interval)
// give up the monitor until we're back from Wait()
nsresult rv =
PR_Wait(mMonitor, interval) == PR_SUCCESS ?
PR_Wait(mReentrantMonitor, interval) == PR_SUCCESS ?
NS_OK : NS_ERROR_FAILURE;
// restore saved state

View File

@ -75,7 +75,7 @@ class NS_COM_GLUE BlockingResourceBase
{
public:
// Needs to be kept in sync with kResourceTypeNames.
enum BlockingResourceType { eMutex, eMonitor, eCondVar };
enum BlockingResourceType { eMutex, eReentrantMonitor, eCondVar };
/**
* kResourceTypeName

View File

@ -129,8 +129,8 @@ EXPORTS_mozilla = \
FileUtils.h \
GenericFactory.h \
IntentionalCrash.h \
Monitor.h \
Mutex.h \
ReentrantMonitor.h \
SSE.h \
arm.h \
unused.h \

View File

@ -36,8 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_Monitor_h
#define mozilla_Monitor_h
#ifndef mozilla_ReentrantMonitor_h
#define mozilla_ReentrantMonitor_h
#include "prmon.h"
@ -46,54 +46,51 @@
//
// Provides:
//
// - Monitor, a Java-like monitor
// - MonitorAutoEnter, an RAII class for ensuring that Monitors are properly
// entered and exited
// - ReentrantMonitor, a Java-like monitor
// - ReentrantMonitorAutoEnter, an RAII class for ensuring that
// ReentrantMonitors are properly entered and exited
//
// Using MonitorAutoEnter is MUCH preferred to making bare calls to
// Monitor.Enter and Exit.
// Using ReentrantMonitorAutoEnter is MUCH preferred to making bare calls to
// ReentrantMonitor.Enter and Exit.
//
namespace mozilla {
/**
* Monitor
* ReentrantMonitor
* Java-like monitor.
* When possible, use MonitorAutoEnter to hold this monitor within a
* When possible, use ReentrantMonitorAutoEnter to hold this monitor within a
* scope, instead of calling Enter/Exit directly.
**/
class NS_COM_GLUE Monitor : BlockingResourceBase
class NS_COM_GLUE ReentrantMonitor : BlockingResourceBase
{
public:
/**
* Monitor
* ReentrantMonitor
* @param aName A name which can reference this monitor
* @returns If failure, nsnull
* If success, a valid Monitor*, which must be destroyed
* by Monitor::DestroyMonitor()
**/
Monitor(const char* aName) :
BlockingResourceBase(aName, eMonitor)
*/
ReentrantMonitor(const char* aName) :
BlockingResourceBase(aName, eReentrantMonitor)
#ifdef DEBUG
, mEntryCount(0)
#endif
{
MOZ_COUNT_CTOR(Monitor);
mMonitor = PR_NewMonitor();
if (!mMonitor)
NS_RUNTIMEABORT("Can't allocate mozilla::Monitor");
MOZ_COUNT_CTOR(ReentrantMonitor);
mReentrantMonitor = PR_NewMonitor();
if (!mReentrantMonitor)
NS_RUNTIMEABORT("Can't allocate mozilla::ReentrantMonitor");
}
/**
* ~Monitor
* ~ReentrantMonitor
**/
~Monitor()
~ReentrantMonitor()
{
NS_ASSERTION(mMonitor,
"improperly constructed Monitor or double free");
PR_DestroyMonitor(mMonitor);
mMonitor = 0;
MOZ_COUNT_DTOR(Monitor);
NS_ASSERTION(mReentrantMonitor,
"improperly constructed ReentrantMonitor or double free");
PR_DestroyMonitor(mReentrantMonitor);
mReentrantMonitor = 0;
MOZ_COUNT_DTOR(ReentrantMonitor);
}
#ifndef DEBUG
@ -103,7 +100,7 @@ public:
**/
void Enter()
{
PR_EnterMonitor(mMonitor);
PR_EnterMonitor(mReentrantMonitor);
}
/**
@ -112,7 +109,7 @@ public:
**/
void Exit()
{
PR_ExitMonitor(mMonitor);
PR_ExitMonitor(mReentrantMonitor);
}
/**
@ -121,7 +118,7 @@ public:
**/
nsresult Wait(PRIntervalTime interval = PR_INTERVAL_NO_TIMEOUT)
{
return PR_Wait(mMonitor, interval) == PR_SUCCESS ?
return PR_Wait(mReentrantMonitor, interval) == PR_SUCCESS ?
NS_OK : NS_ERROR_FAILURE;
}
@ -138,7 +135,7 @@ public:
**/
nsresult Notify()
{
return PR_Notify(mMonitor) == PR_SUCCESS
return PR_Notify(mReentrantMonitor) == PR_SUCCESS
? NS_OK : NS_ERROR_FAILURE;
}
@ -148,7 +145,7 @@ public:
**/
nsresult NotifyAll()
{
return PR_NotifyAll(mMonitor) == PR_SUCCESS
return PR_NotifyAll(mReentrantMonitor) == PR_SUCCESS
? NS_OK : NS_ERROR_FAILURE;
}
@ -159,7 +156,7 @@ public:
**/
void AssertCurrentThreadIn()
{
PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mMonitor);
PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mReentrantMonitor);
}
/**
@ -182,11 +179,11 @@ public:
#endif // ifdef DEBUG
private:
Monitor();
Monitor(const Monitor&);
Monitor& operator =(const Monitor&);
ReentrantMonitor();
ReentrantMonitor(const ReentrantMonitor&);
ReentrantMonitor& operator =(const ReentrantMonitor&);
PRMonitor* mMonitor;
PRMonitor* mReentrantMonitor;
#ifdef DEBUG
PRInt32 mEntryCount;
#endif
@ -194,13 +191,13 @@ private:
/**
* MonitorAutoEnter
* Enters the Monitor when it enters scope, and exits it when it leaves
* scope.
* ReentrantMonitorAutoEnter
* Enters the ReentrantMonitor when it enters scope, and exits it when
* it leaves scope.
*
* MUCH PREFERRED to bare calls to Monitor.Enter and Exit.
* MUCH PREFERRED to bare calls to ReentrantMonitor.Enter and Exit.
*/
class NS_COM_GLUE NS_STACK_CLASS MonitorAutoEnter
class NS_COM_GLUE NS_STACK_CLASS ReentrantMonitorAutoEnter
{
public:
/**
@ -208,48 +205,47 @@ public:
* The constructor aquires the given lock. The destructor
* releases the lock.
*
* @param aMonitor A valid mozilla::Monitor* returned by
* mozilla::Monitor::NewMonitor.
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*.
**/
MonitorAutoEnter(mozilla::Monitor &aMonitor) :
mMonitor(&aMonitor)
ReentrantMonitorAutoEnter(mozilla::ReentrantMonitor &aReentrantMonitor) :
mReentrantMonitor(&aReentrantMonitor)
{
NS_ASSERTION(mMonitor, "null monitor");
mMonitor->Enter();
NS_ASSERTION(mReentrantMonitor, "null monitor");
mReentrantMonitor->Enter();
}
~MonitorAutoEnter(void)
~ReentrantMonitorAutoEnter(void)
{
mMonitor->Exit();
mReentrantMonitor->Exit();
}
nsresult Wait(PRIntervalTime interval = PR_INTERVAL_NO_TIMEOUT)
{
return mMonitor->Wait(interval);
return mReentrantMonitor->Wait(interval);
}
nsresult Notify()
{
return mMonitor->Notify();
return mReentrantMonitor->Notify();
}
nsresult NotifyAll()
{
return mMonitor->NotifyAll();
return mReentrantMonitor->NotifyAll();
}
private:
MonitorAutoEnter();
MonitorAutoEnter(const MonitorAutoEnter&);
MonitorAutoEnter& operator =(const MonitorAutoEnter&);
ReentrantMonitorAutoEnter();
ReentrantMonitorAutoEnter(const ReentrantMonitorAutoEnter&);
ReentrantMonitorAutoEnter& operator =(const ReentrantMonitorAutoEnter&);
static void* operator new(size_t) CPP_THROW_NEW;
static void operator delete(void*);
mozilla::Monitor* mMonitor;
mozilla::ReentrantMonitor* mReentrantMonitor;
};
} // namespace mozilla
#endif // ifndef mozilla_Monitor_h
#endif // ifndef mozilla_ReentrantMonitor_h

View File

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIPipe.h"
#include "nsIEventTarget.h"
#include "nsISeekableStream.h"
@ -260,7 +260,7 @@ protected:
nsPipeInputStream mInput;
nsPipeOutputStream mOutput;
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
nsSegmentedBuffer mBuffer;
char* mReadCursor;
@ -320,7 +320,7 @@ protected:
nsPipe::nsPipe()
: mInput(this)
, mOutput(this)
, mMonitor("nsPipe.mMonitor")
, mReentrantMonitor("nsPipe.mReentrantMonitor")
, mReadCursor(nsnull)
, mReadLimit(nsnull)
, mWriteSegment(-1)
@ -405,7 +405,7 @@ nsPipe::PeekSegment(PRUint32 index, char *&cursor, char *&limit)
nsresult
nsPipe::GetReadSegment(const char *&segment, PRUint32 &segmentLen)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (mReadCursor == mReadLimit)
return NS_FAILED(mStatus) ? mStatus : NS_BASE_STREAM_WOULD_BLOCK;
@ -422,7 +422,7 @@ nsPipe::AdvanceReadCursor(PRUint32 bytesRead)
nsPipeEvents events;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
LOG(("III advancing read cursor by %u\n", bytesRead));
NS_ASSERTION(bytesRead <= mBuffer.GetSegmentSize(), "read too much");
@ -477,7 +477,7 @@ nsPipe::AdvanceReadCursor(PRUint32 bytesRead)
nsresult
nsPipe::GetWriteSegment(char *&segment, PRUint32 &segmentLen)
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (NS_FAILED(mStatus))
return mStatus;
@ -520,7 +520,7 @@ nsPipe::AdvanceWriteCursor(PRUint32 bytesWritten)
nsPipeEvents events;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
LOG(("OOO advancing write cursor by %u\n", bytesWritten));
@ -577,7 +577,7 @@ nsPipe::OnPipeException(nsresult reason, PRBool outputOnly)
nsPipeEvents events;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
// if we've already hit an exception, then ignore this one.
if (NS_FAILED(mStatus))
@ -643,7 +643,7 @@ nsPipeInputStream::Wait()
{
NS_ASSERTION(mBlocking, "wait on non-blocking pipe input stream");
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
while (NS_SUCCEEDED(mPipe->mStatus) && (mAvailable == 0)) {
LOG(("III pipe input: waiting for data\n"));
@ -737,7 +737,7 @@ nsPipeInputStream::Close()
NS_IMETHODIMP
nsPipeInputStream::Available(PRUint32 *result)
{
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
// return error if pipe closed
if (!mAvailable && NS_FAILED(mPipe->mStatus))
@ -843,7 +843,7 @@ nsPipeInputStream::AsyncWait(nsIInputStreamCallback *callback,
nsPipeEvents pipeEvents;
{
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
// replace a pending callback
mCallback = 0;
@ -884,7 +884,7 @@ nsPipeInputStream::Seek(PRInt32 whence, PRInt64 offset)
NS_IMETHODIMP
nsPipeInputStream::Tell(PRInt64 *offset)
{
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
// return error if pipe closed
if (!mAvailable && NS_FAILED(mPipe->mStatus))
@ -914,7 +914,7 @@ nsPipeInputStream::Search(const char *forString,
{
LOG(("III Search [for=%s ic=%u]\n", forString, ignoreCase));
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
char *cursor1, *limit1;
PRUint32 index = 0, offset = 0;
@ -1002,7 +1002,7 @@ nsPipeOutputStream::Wait()
{
NS_ASSERTION(mBlocking, "wait on non-blocking pipe output stream");
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
if (NS_SUCCEEDED(mPipe->mStatus) && !mWritable) {
LOG(("OOO pipe output: waiting for space\n"));
@ -1224,7 +1224,7 @@ nsPipeOutputStream::AsyncWait(nsIOutputStreamCallback *callback,
nsPipeEvents pipeEvents;
{
MonitorAutoEnter mon(mPipe->mMonitor);
ReentrantMonitorAutoEnter mon(mPipe->mReentrantMonitor);
// replace a pending callback
mCallback = 0;

View File

@ -51,7 +51,7 @@
#include "nsITestProxy.h"
#include "nsISupportsPrimitives.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
#include "nsIRunnable.h"
#include "nsIProxyObjectManager.h"
@ -100,7 +100,7 @@ class ProxyTest : public nsIRunnable,
public:
ProxyTest()
: mCounterLock("ProxyTest.mCounterLock")
, mEvilMonitor("ProxyTest.mEvilMonitor")
, mEvilReentrantMonitor("ProxyTest.mEvilReentrantMonitor")
, mCounter(0)
{}
@ -181,8 +181,8 @@ public:
{
/* be evil here and hang */
MutexAutoUnlock counterUnlock(mCounterLock);
MonitorAutoEnter evilMonitor(mEvilMonitor);
nsresult rv = evilMonitor.Wait();
ReentrantMonitorAutoEnter evilReentrantMonitor(mEvilReentrantMonitor);
nsresult rv = evilReentrantMonitor.Wait();
NS_ENSURE_SUCCESS(rv, rv);
break;
}
@ -191,8 +191,8 @@ public:
{
/* okay, we had our fun, un-hang */
MutexAutoUnlock counterUnlock(mCounterLock);
MonitorAutoEnter evilMonitor(mEvilMonitor);
nsresult rv = evilMonitor.Notify();
ReentrantMonitorAutoEnter evilReentrantMonitor(mEvilReentrantMonitor);
nsresult rv = evilReentrantMonitor.Notify();
NS_ENSURE_SUCCESS(rv, rv);
break;
}
@ -228,7 +228,7 @@ protected:
private:
Mutex mCounterLock;
Monitor mEvilMonitor;
ReentrantMonitor mEvilReentrantMonitor;
PRInt32 mCounter;
nsCOMPtr<nsIThread> mThreadOne;
nsCOMPtr<nsIThread> mThreadTwo;

View File

@ -51,7 +51,7 @@ using namespace mozilla;
static int DEBUG_TotalInfos = 0;
static int DEBUG_CurrentInfos = 0;
static int DEBUG_MaxInfos = 0;
static int DEBUG_MonitorEntryCount = 0;
static int DEBUG_ReentrantMonitorEntryCount = 0;
#define LOG_INFO_CREATE(t) \
DEBUG_TotalInfos++; \
@ -63,7 +63,7 @@ static int DEBUG_MonitorEntryCount = 0;
DEBUG_CurrentInfos-- /* no ';' */
#define LOG_INFO_MONITOR_ENTRY \
DEBUG_MonitorEntryCount++ /* no ';' */
DEBUG_ReentrantMonitorEntryCount++ /* no ';' */
#else /* SHOW_INFO_COUNT_STATS */
@ -620,7 +620,7 @@ nsresult
xptiInterfaceEntry::GetInterfaceInfo(xptiInterfaceInfo** info)
{
#ifdef DEBUG
xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet()->mTableMonitor.
xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet()->mTableReentrantMonitor.
AssertCurrentThreadIn();
#endif
LOG_INFO_MONITOR_ENTRY;
@ -652,8 +652,8 @@ xptiInterfaceEntry::LockedInvalidateInterfaceInfo()
PRBool
xptiInterfaceInfo::BuildParent()
{
mozilla::MonitorAutoEnter monitor(xptiInterfaceInfoManager::GetSingleton()->
GetWorkingSet()->mTableMonitor);
mozilla::ReentrantMonitorAutoEnter monitor(xptiInterfaceInfoManager::GetSingleton()->
GetWorkingSet()->mTableReentrantMonitor);
NS_ASSERTION(mEntry &&
mEntry->IsFullyResolved() &&
!mParent &&
@ -695,9 +695,9 @@ xptiInterfaceInfo::Release(void)
NS_LOG_RELEASE(this, cnt, "xptiInterfaceInfo");
if(!cnt)
{
mozilla::MonitorAutoEnter monitor(xptiInterfaceInfoManager::
mozilla::ReentrantMonitorAutoEnter monitor(xptiInterfaceInfoManager::
GetSingleton()->GetWorkingSet()->
mTableMonitor);
mTableReentrantMonitor);
LOG_INFO_MONITOR_ENTRY;
// If GetInterfaceInfo added and *released* a reference before we

View File

@ -233,7 +233,7 @@ xptiInterfaceInfoManager::RegisterXPTHeader(XPTHeader* aHeader)
xptiTypelibGuts* typelib = xptiTypelibGuts::Create(aHeader);
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
for(PRUint16 k = 0; k < aHeader->num_interfaces; k++)
VerifyAndAddEntryIfNew(aHeader->interface_directory + k, k, typelib);
}
@ -254,7 +254,7 @@ xptiInterfaceInfoManager::VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* ifa
if (!iface->interface_descriptor)
return;
mWorkingSet.mTableMonitor.AssertCurrentThreadIn();
mWorkingSet.mTableReentrantMonitor.AssertCurrentThreadIn();
xptiInterfaceEntry* entry = mWorkingSet.mIIDTable.Get(iface->iid);
if (entry) {
// XXX validate this info to find possible inconsistencies
@ -306,7 +306,7 @@ EntryToInfo(xptiInterfaceEntry* entry, nsIInterfaceInfo **_retval)
xptiInterfaceEntry*
xptiInterfaceInfoManager::GetInterfaceEntryForIID(const nsIID *iid)
{
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
return mWorkingSet.mIIDTable.Get(*iid);
}
@ -316,7 +316,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForIID(const nsIID * iid, nsIInte
NS_ASSERTION(iid, "bad param");
NS_ASSERTION(_retval, "bad param");
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
xptiInterfaceEntry* entry = mWorkingSet.mIIDTable.Get(*iid);
return EntryToInfo(entry, _retval);
}
@ -327,7 +327,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetInfoForName(const char *name, nsIInte
NS_ASSERTION(name, "bad param");
NS_ASSERTION(_retval, "bad param");
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
xptiInterfaceEntry* entry = mWorkingSet.mNameTable.Get(name);
return EntryToInfo(entry, _retval);
}
@ -338,7 +338,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetIIDForName(const char *name, nsIID *
NS_ASSERTION(name, "bad param");
NS_ASSERTION(_retval, "bad param");
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
xptiInterfaceEntry* entry = mWorkingSet.mNameTable.Get(name);
if (!entry) {
*_retval = nsnull;
@ -354,7 +354,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::GetNameForIID(const nsIID * iid, char **
NS_ASSERTION(iid, "bad param");
NS_ASSERTION(_retval, "bad param");
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
xptiInterfaceEntry* entry = mWorkingSet.mIIDTable.Get(*iid);
if (!entry) {
*_retval = nsnull;
@ -388,7 +388,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateInterfaces(nsIEnumerator **_ret
if (!array)
return NS_ERROR_UNEXPECTED;
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
mWorkingSet.mNameTable.EnumerateRead(xpti_ArrayAppender, array);
return array->Enumerate(_retval);
@ -424,7 +424,7 @@ NS_IMETHODIMP xptiInterfaceInfoManager::EnumerateInterfacesWhoseNamesStartWith(c
if (!array)
return NS_ERROR_UNEXPECTED;
MonitorAutoEnter monitor(mWorkingSet.mTableMonitor);
ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor);
ArrayAndPrefix args = {array, prefix, PL_strlen(prefix)};
mWorkingSet.mNameTable.EnumerateRead(xpti_ArrayPrefixAppender, &args);

View File

@ -76,7 +76,7 @@ xptiTypelibGuts::GetEntryAt(PRUint16 i)
xptiInterfaceInfoManager::GetSingleton()->GetWorkingSet();
{
MonitorAutoEnter monitor(set->mTableMonitor);
ReentrantMonitorAutoEnter monitor(set->mTableReentrantMonitor);
if (iface->iid.Equals(zeroIID))
r = set->mNameTable.Get(iface->name);
else

View File

@ -48,7 +48,7 @@ using namespace mozilla;
#define XPTI_HASHTABLE_SIZE 2048
xptiWorkingSet::xptiWorkingSet()
: mTableMonitor("xptiWorkingSet::mTableMonitor")
: mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
{
MOZ_COUNT_CTOR(xptiWorkingSet);
@ -69,7 +69,7 @@ xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
void
xptiWorkingSet::InvalidateInterfaceInfos()
{
MonitorAutoEnter monitor(mTableMonitor);
ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
mNameTable.EnumerateRead(xpti_Invalidator, NULL);
}

View File

@ -62,7 +62,7 @@
#include "nsAppDirectoryServiceDefs.h"
#include "nsIWeakReference.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
#include "nsCRT.h"
@ -184,7 +184,7 @@ public:
// * any read from or write to mIIDTable or mNameTable
// * any writing to the links between an xptiInterfaceEntry
// and its xptiInterfaceInfo (mEntry/mInfo)
mozilla::Monitor mTableMonitor;
mozilla::ReentrantMonitor mTableReentrantMonitor;
nsDataHashtable<nsIDHashKey, xptiInterfaceEntry*> mIIDTable;
nsDataHashtable<nsDepCharHashKey, xptiInterfaceEntry*> mNameTable;
};
@ -429,7 +429,7 @@ class xptiInterfaceInfoManager
NS_DECL_NSIINTERFACEINFOMANAGER
NS_DECL_NSIINTERFACEINFOSUPERMANAGER
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
typedef mozilla::Mutex Mutex;
public:

View File

@ -45,7 +45,7 @@
#include "nsMemory.h"
#include "mozilla/CondVar.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "mozilla/Mutex.h"
#include "TestHarness.h"
@ -393,7 +393,7 @@ Sanity3()
nsresult
Sanity4_Child()
{
mozilla::Monitor m1("dd.sanity4.m1");
mozilla::ReentrantMonitor m1("dd.sanity4.m1");
mozilla::Mutex m2("dd.sanity4.m2");
m1.Enter();
m2.Lock();
@ -405,11 +405,11 @@ nsresult
Sanity4()
{
const char* const tokens[] = {
"Re-entering Monitor after acquiring other resources",
"Re-entering ReentrantMonitor after acquiring other resources",
"###!!! ERROR: Potential deadlock detected",
"=== Cyclical dependency starts at\n--- Monitor : dd.sanity4.m1",
"=== Cyclical dependency starts at\n--- ReentrantMonitor : dd.sanity4.m1",
"--- Next dependency:\n--- Mutex : dd.sanity4.m2",
"=== Cycle completed at\n--- Monitor : dd.sanity4.m1",
"=== Cycle completed at\n--- ReentrantMonitor : dd.sanity4.m1",
"###!!! ASSERTION: Potential deadlock detected",
0
};

View File

@ -48,7 +48,7 @@
#include "nsXPCOMCIDInternal.h"
#include "prmon.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
using namespace mozilla;
#ifdef DEBUG
@ -89,30 +89,30 @@ NS_DEFINE_CID(kFactoryCID2, FACTORY_CID2);
PRInt32 gComponent1Count = 0;
PRInt32 gComponent2Count = 0;
Monitor* gMonitor = nsnull;
ReentrantMonitor* gReentrantMonitor = nsnull;
PRBool gCreateInstanceCalled = PR_FALSE;
PRBool gMainThreadWaiting = PR_FALSE;
class AutoCreateAndDestroyMonitor
class AutoCreateAndDestroyReentrantMonitor
{
public:
AutoCreateAndDestroyMonitor(Monitor** aMonitorPtr)
: mMonitorPtr(aMonitorPtr) {
*aMonitorPtr =
new Monitor("TestRacingServiceManager::AutoMon");
TEST_ASSERTION(*aMonitorPtr, "Out of memory!");
AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
: mReentrantMonitorPtr(aReentrantMonitorPtr) {
*aReentrantMonitorPtr =
new ReentrantMonitor("TestRacingServiceManager::AutoMon");
TEST_ASSERTION(*aReentrantMonitorPtr, "Out of memory!");
}
~AutoCreateAndDestroyMonitor() {
if (*mMonitorPtr) {
delete *mMonitorPtr;
*mMonitorPtr = nsnull;
~AutoCreateAndDestroyReentrantMonitor() {
if (*mReentrantMonitorPtr) {
delete *mReentrantMonitorPtr;
*mReentrantMonitorPtr = nsnull;
}
}
private:
Monitor** mMonitorPtr;
ReentrantMonitor** mReentrantMonitorPtr;
};
class Factory : public nsIFactory
@ -185,7 +185,7 @@ Factory::CreateInstance(nsISupports* aDelegate,
TEST_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
gCreateInstanceCalled = PR_TRUE;
mon.Notify();
@ -226,7 +226,7 @@ NS_IMETHODIMP
Runnable::Run()
{
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
while (!gMainThreadWaiting) {
mon.Wait();
@ -285,7 +285,7 @@ int main(int argc, char** argv)
ScopedXPCOM xpcom("RacingServiceManager");
NS_ENSURE_FALSE(xpcom.failed(), 1);
AutoCreateAndDestroyMonitor mon(&gMonitor);
AutoCreateAndDestroyReentrantMonitor mon(&gReentrantMonitor);
nsRefPtr<Runnable> runnable = new Runnable();
NS_ENSURE_TRUE(runnable, 1);
@ -296,7 +296,7 @@ int main(int argc, char** argv)
NS_ENSURE_SUCCESS(rv, 1);
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
gMainThreadWaiting = PR_TRUE;
mon.Notify();
@ -318,7 +318,7 @@ int main(int argc, char** argv)
NS_ENSURE_SUCCESS(rv, 1);
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
gMainThreadWaiting = PR_TRUE;
mon.Notify();

View File

@ -48,7 +48,7 @@
#include "prmon.h"
#include "prthread.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
using namespace mozilla;
#define NUMBER_OF_THREADS 4
@ -59,7 +59,7 @@ using namespace mozilla;
static nsIThread** gCreatedThreadList = nsnull;
static nsIThread** gShutDownThreadList = nsnull;
static Monitor* gMonitor = nsnull;
static ReentrantMonitor* gReentrantMonitor = nsnull;
static PRBool gAllRunnablesPosted = PR_FALSE;
static PRBool gAllThreadsCreated = PR_FALSE;
@ -92,7 +92,7 @@ Listener::OnThreadCreated()
nsCOMPtr<nsIThread> current(do_GetCurrentThread());
TEST_ASSERTION(current, "Couldn't get current thread!");
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
while (!gAllRunnablesPosted) {
mon.Wait();
@ -122,7 +122,7 @@ Listener::OnThreadShuttingDown()
nsCOMPtr<nsIThread> current(do_GetCurrentThread());
TEST_ASSERTION(current, "Couldn't get current thread!");
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
for (PRUint32 i = 0; i < NUMBER_OF_THREADS; i++) {
nsIThread* thread = gShutDownThreadList[i];
@ -142,24 +142,24 @@ Listener::OnThreadShuttingDown()
return NS_ERROR_FAILURE;
}
class AutoCreateAndDestroyMonitor
class AutoCreateAndDestroyReentrantMonitor
{
public:
AutoCreateAndDestroyMonitor(Monitor** aMonitorPtr)
: mMonitorPtr(aMonitorPtr) {
*aMonitorPtr = new Monitor("TestThreadPoolListener::AutoMon");
TEST_ASSERTION(*aMonitorPtr, "Out of memory!");
AutoCreateAndDestroyReentrantMonitor(ReentrantMonitor** aReentrantMonitorPtr)
: mReentrantMonitorPtr(aReentrantMonitorPtr) {
*aReentrantMonitorPtr = new ReentrantMonitor("TestThreadPoolListener::AutoMon");
TEST_ASSERTION(*aReentrantMonitorPtr, "Out of memory!");
}
~AutoCreateAndDestroyMonitor() {
if (*mMonitorPtr) {
delete *mMonitorPtr;
*mMonitorPtr = nsnull;
~AutoCreateAndDestroyReentrantMonitor() {
if (*mReentrantMonitorPtr) {
delete *mReentrantMonitorPtr;
*mReentrantMonitorPtr = nsnull;
}
}
private:
Monitor** mMonitorPtr;
ReentrantMonitor** mReentrantMonitorPtr;
};
int main(int argc, char** argv)
@ -173,8 +173,8 @@ int main(int argc, char** argv)
nsIThread* shutDownThreadList[NUMBER_OF_THREADS] = { nsnull };
gShutDownThreadList = shutDownThreadList;
AutoCreateAndDestroyMonitor newMon(&gMonitor);
NS_ENSURE_TRUE(gMonitor, 1);
AutoCreateAndDestroyReentrantMonitor newMon(&gReentrantMonitor);
NS_ENSURE_TRUE(gReentrantMonitor, 1);
nsresult rv;
@ -205,7 +205,7 @@ int main(int argc, char** argv)
NS_ENSURE_SUCCESS(rv, 1);
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
for (PRUint32 i = 0; i < NUMBER_OF_THREADS; i++) {
nsCOMPtr<nsIRunnable> runnable = new nsRunnable();
@ -220,7 +220,7 @@ int main(int argc, char** argv)
}
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
while (!gAllThreadsCreated) {
mon.Wait();
}
@ -230,7 +230,7 @@ int main(int argc, char** argv)
NS_ENSURE_SUCCESS(rv, 1);
{
MonitorAutoEnter mon(*gMonitor);
ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
while (!gAllThreadsShutDown) {
mon.Wait();
}

View File

@ -47,7 +47,7 @@
#include "prinrval.h"
#include "prmon.h"
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
using namespace mozilla;
typedef nsresult(*TestFuncPtr)();
@ -80,26 +80,26 @@ private:
nsCOMPtr<nsIThread> mThread;
};
class AutoCreateAndDestroyMonitor
class AutoCreateAndDestroyReentrantMonitor
{
public:
AutoCreateAndDestroyMonitor() {
mMonitor = new Monitor("TestTimers::AutoMon");
NS_ASSERTION(mMonitor, "Out of memory!");
AutoCreateAndDestroyReentrantMonitor() {
mReentrantMonitor = new ReentrantMonitor("TestTimers::AutoMon");
NS_ASSERTION(mReentrantMonitor, "Out of memory!");
}
~AutoCreateAndDestroyMonitor() {
if (mMonitor) {
delete mMonitor;
~AutoCreateAndDestroyReentrantMonitor() {
if (mReentrantMonitor) {
delete mReentrantMonitor;
}
}
operator Monitor* () {
return mMonitor;
operator ReentrantMonitor* () {
return mReentrantMonitor;
}
private:
Monitor* mMonitor;
ReentrantMonitor* mReentrantMonitor;
};
class TimerCallback : public nsITimerCallback
@ -107,13 +107,13 @@ class TimerCallback : public nsITimerCallback
public:
NS_DECL_ISUPPORTS
TimerCallback(nsIThread** aThreadPtr, Monitor* aMonitor)
: mThreadPtr(aThreadPtr), mMonitor(aMonitor) { }
TimerCallback(nsIThread** aThreadPtr, ReentrantMonitor* aReentrantMonitor)
: mThreadPtr(aThreadPtr), mReentrantMonitor(aReentrantMonitor) { }
NS_IMETHOD Notify(nsITimer* aTimer) {
nsCOMPtr<nsIThread> current(do_GetCurrentThread());
MonitorAutoEnter mon(*mMonitor);
ReentrantMonitorAutoEnter mon(*mReentrantMonitor);
NS_ASSERTION(!*mThreadPtr, "Timer called back more than once!");
*mThreadPtr = current;
@ -124,7 +124,7 @@ public:
}
private:
nsIThread** mThreadPtr;
Monitor* mMonitor;
ReentrantMonitor* mReentrantMonitor;
};
NS_IMPL_THREADSAFE_ISUPPORTS1(TimerCallback, nsITimerCallback)
@ -132,7 +132,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(TimerCallback, nsITimerCallback)
nsresult
TestTargetedTimers()
{
AutoCreateAndDestroyMonitor newMon;
AutoCreateAndDestroyReentrantMonitor newMon;
NS_ENSURE_TRUE(newMon, NS_ERROR_OUT_OF_MEMORY);
AutoTestThread testThread;
@ -157,7 +157,7 @@ TestTargetedTimers()
nsITimer::TYPE_ONE_SHOT);
NS_ENSURE_SUCCESS(rv, rv);
MonitorAutoEnter mon(*newMon);
ReentrantMonitorAutoEnter mon(*newMon);
while (!notifiedThread) {
mon.Wait();
}

View File

@ -49,7 +49,7 @@ static PRLogModuleInfo *sLog = PR_NewLogModule("nsEventQueue");
#define LOG(args) PR_LOG(sLog, PR_LOG_DEBUG, args)
nsEventQueue::nsEventQueue()
: mMonitor("nsEventQueue.mMonitor")
: mReentrantMonitor("nsEventQueue.mReentrantMonitor")
, mHead(nsnull)
, mTail(nsnull)
, mOffsetHead(0)
@ -71,7 +71,7 @@ PRBool
nsEventQueue::GetEvent(PRBool mayWait, nsIRunnable **result)
{
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
while (IsEmpty()) {
if (!mayWait) {
@ -107,7 +107,7 @@ nsEventQueue::PutEvent(nsIRunnable *runnable)
nsRefPtr<nsIRunnable> event(runnable);
PRBool rv = PR_TRUE;
{
MonitorAutoEnter mon(mMonitor);
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
if (!mHead) {
mHead = NewPage();

View File

@ -40,13 +40,13 @@
#define nsEventQueue_h__
#include <stdlib.h>
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIRunnable.h"
// A threadsafe FIFO event queue...
class NS_COM nsEventQueue
{
typedef mozilla::Monitor Monitor;
typedef mozilla::ReentrantMonitor ReentrantMonitor;
public:
nsEventQueue();
@ -82,8 +82,8 @@ public:
}
// Expose the event queue's monitor for "power users"
Monitor& GetMonitor() {
return mMonitor;
ReentrantMonitor& GetReentrantMonitor() {
return mReentrantMonitor;
}
private:
@ -109,7 +109,7 @@ private:
free(p);
}
Monitor mMonitor;
ReentrantMonitor mReentrantMonitor;
Page *mHead;
Page *mTail;

View File

@ -36,7 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Monitor.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsThread.h"
#include "nsThreadManager.h"
#include "nsIClassInfoImpl.h"
@ -184,7 +184,7 @@ public:
void Wait() {
if (mInitialized) // Maybe avoid locking...
return;
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
while (!mInitialized)
mon.Wait();
}
@ -196,7 +196,7 @@ public:
private:
NS_IMETHOD Run() {
MonitorAutoEnter mon(mMon);
ReentrantMonitorAutoEnter mon(mMon);
mInitialized = PR_TRUE;
mon.Notify();
return NS_OK;
@ -207,7 +207,7 @@ private:
, mInitialized(PR_FALSE) {
}
Monitor mMon;
ReentrantMonitor mMon;
PRBool mInitialized;
};

View File

@ -92,7 +92,7 @@ nsThreadPool::PutEvent(nsIRunnable *event)
PRBool spawnThread = PR_FALSE;
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
LOG(("THRD-P(%p) put [%d %d %d]\n", this, mIdleCount, mThreads.Count(),
mThreadLimit));
@ -115,7 +115,7 @@ nsThreadPool::PutEvent(nsIRunnable *event)
PRBool killThread = PR_FALSE;
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
if (mThreads.Count() < (PRInt32) mThreadLimit) {
mThreads.AppendObject(thread);
} else {
@ -167,7 +167,7 @@ nsThreadPool::Run()
nsCOMPtr<nsIThreadPoolListener> listener;
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
listener = mListener;
}
@ -178,7 +178,7 @@ nsThreadPool::Run()
do {
nsCOMPtr<nsIRunnable> event;
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
if (!mEvents.GetPendingEvent(getter_AddRefs(event))) {
PRIntervalTime now = PR_IntervalNow();
PRIntervalTime timeout = PR_MillisecondsToInterval(mIdleThreadTimeout);
@ -277,7 +277,7 @@ nsThreadPool::Shutdown()
nsCOMArray<nsIThread> threads;
nsCOMPtr<nsIThreadPoolListener> listener;
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
mShutdown = PR_TRUE;
mon.NotifyAll();
@ -309,7 +309,7 @@ nsThreadPool::GetThreadLimit(PRUint32 *value)
NS_IMETHODIMP
nsThreadPool::SetThreadLimit(PRUint32 value)
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
mThreadLimit = value;
if (mIdleThreadLimit > mThreadLimit)
mIdleThreadLimit = mThreadLimit;
@ -327,7 +327,7 @@ nsThreadPool::GetIdleThreadLimit(PRUint32 *value)
NS_IMETHODIMP
nsThreadPool::SetIdleThreadLimit(PRUint32 value)
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
mIdleThreadLimit = value;
if (mIdleThreadLimit > mThreadLimit)
mIdleThreadLimit = mThreadLimit;
@ -345,7 +345,7 @@ nsThreadPool::GetIdleThreadTimeout(PRUint32 *value)
NS_IMETHODIMP
nsThreadPool::SetIdleThreadTimeout(PRUint32 value)
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
mIdleThreadTimeout = value;
mon.NotifyAll(); // wake up threads so they observe this change
return NS_OK;
@ -354,7 +354,7 @@ nsThreadPool::SetIdleThreadTimeout(PRUint32 value)
NS_IMETHODIMP
nsThreadPool::GetListener(nsIThreadPoolListener** aListener)
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
NS_IF_ADDREF(*aListener = mListener);
return NS_OK;
}
@ -364,7 +364,7 @@ nsThreadPool::SetListener(nsIThreadPoolListener* aListener)
{
nsCOMPtr<nsIThreadPoolListener> swappedListener(aListener);
{
MonitorAutoEnter mon(mEvents.GetMonitor());
ReentrantMonitorAutoEnter mon(mEvents.GetReentrantMonitor());
mListener.swap(swappedListener);
}
return NS_OK;