mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
b=928222 move ReentrantMonitorAutoExit from VideoUtils.h to ReentrantMonitor.h r=bsmedberg
--HG-- extra : transplant_source : %13O%CF%90x%02%B8%B6%A3%EA%AD%03%99%9A7%1B%A0%21%C4%A3
This commit is contained in:
parent
698c365f13
commit
52b6e813b1
@ -35,48 +35,6 @@ struct nsIntSize;
|
||||
// mozilla::Monitor non-reentrant.
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* ReentrantMonitorAutoExit
|
||||
* Exit the ReentrantMonitor when it enters scope, and enters it when it leaves
|
||||
* scope.
|
||||
*
|
||||
* MUCH PREFERRED to bare calls to ReentrantMonitor.Exit and Enter.
|
||||
*/
|
||||
class MOZ_STACK_CLASS ReentrantMonitorAutoExit
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* The constructor releases the given lock. The destructor
|
||||
* acquires the lock. The lock must be held before constructing
|
||||
* this object!
|
||||
*
|
||||
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
|
||||
* must be already locked.
|
||||
**/
|
||||
ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor) :
|
||||
mReentrantMonitor(&aReentrantMonitor)
|
||||
{
|
||||
NS_ASSERTION(mReentrantMonitor, "null monitor");
|
||||
mReentrantMonitor->AssertCurrentThreadIn();
|
||||
mReentrantMonitor->Exit();
|
||||
}
|
||||
|
||||
~ReentrantMonitorAutoExit(void)
|
||||
{
|
||||
mReentrantMonitor->Enter();
|
||||
}
|
||||
|
||||
private:
|
||||
ReentrantMonitorAutoExit();
|
||||
ReentrantMonitorAutoExit(const ReentrantMonitorAutoExit&);
|
||||
ReentrantMonitorAutoExit& operator =(const ReentrantMonitorAutoExit&);
|
||||
static void* operator new(size_t) CPP_THROW_NEW;
|
||||
static void operator delete(void*);
|
||||
|
||||
ReentrantMonitor* mReentrantMonitor;
|
||||
};
|
||||
|
||||
/**
|
||||
* ReentrantMonitorConditionallyEnter
|
||||
*
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "MediaResource.h"
|
||||
#include "WebMReader.h"
|
||||
#include "WebMBufferedParser.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "mozilla/dom/TimeRanges.h"
|
||||
#include "VorbisUtils.h"
|
||||
|
||||
|
@ -212,6 +212,47 @@ private:
|
||||
mozilla::ReentrantMonitor* mReentrantMonitor;
|
||||
};
|
||||
|
||||
/**
|
||||
* ReentrantMonitorAutoExit
|
||||
* Exit the ReentrantMonitor when it enters scope, and enters it when it leaves
|
||||
* scope.
|
||||
*
|
||||
* MUCH PREFERRED to bare calls to ReentrantMonitor.Exit and Enter.
|
||||
*/
|
||||
class MOZ_STACK_CLASS ReentrantMonitorAutoExit
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* The constructor releases the given lock. The destructor
|
||||
* acquires the lock. The lock must be held before constructing
|
||||
* this object!
|
||||
*
|
||||
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
|
||||
* must be already locked.
|
||||
**/
|
||||
ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor) :
|
||||
mReentrantMonitor(&aReentrantMonitor)
|
||||
{
|
||||
NS_ASSERTION(mReentrantMonitor, "null monitor");
|
||||
mReentrantMonitor->AssertCurrentThreadIn();
|
||||
mReentrantMonitor->Exit();
|
||||
}
|
||||
|
||||
~ReentrantMonitorAutoExit(void)
|
||||
{
|
||||
mReentrantMonitor->Enter();
|
||||
}
|
||||
|
||||
private:
|
||||
ReentrantMonitorAutoExit();
|
||||
ReentrantMonitorAutoExit(const ReentrantMonitorAutoExit&);
|
||||
ReentrantMonitorAutoExit& operator =(const ReentrantMonitorAutoExit&);
|
||||
static void* operator new(size_t) CPP_THROW_NEW;
|
||||
static void operator delete(void*);
|
||||
|
||||
ReentrantMonitor* mReentrantMonitor;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user