Add pointer constructor to CriticalSectionScoped.
Mainly added to simplyfy the code, e.g. when having critsect as scoped_ptr in classes. Review URL: http://webrtc-codereview.appspot.com/302005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1144 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
af225d6bf6
commit
b19582b7dc
@ -33,18 +33,26 @@ public:
|
|||||||
virtual void Leave() = 0;
|
virtual void Leave() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// RAII extension of the critical section. Prevents Enter/Leave missmatches and
|
// RAII extension of the critical section. Prevents Enter/Leave mismatches and
|
||||||
// provides more compact critical section syntax.
|
// provides more compact critical section syntax.
|
||||||
class CriticalSectionScoped
|
class CriticalSectionScoped
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CriticalSectionScoped(CriticalSectionWrapper& critsec)
|
// Deprecated, don't add more users of this constructor.
|
||||||
:
|
// TODO(mflodman) Remove this version of the constructor when no one is
|
||||||
_ptrCritSec(&critsec)
|
// using it any longer.
|
||||||
|
explicit CriticalSectionScoped(CriticalSectionWrapper& critsec)
|
||||||
|
: _ptrCritSec(&critsec)
|
||||||
{
|
{
|
||||||
_ptrCritSec->Enter();
|
_ptrCritSec->Enter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit CriticalSectionScoped(CriticalSectionWrapper* critsec)
|
||||||
|
: _ptrCritSec(critsec)
|
||||||
|
{
|
||||||
|
_ptrCritSec->Enter();
|
||||||
|
}
|
||||||
|
|
||||||
~CriticalSectionScoped()
|
~CriticalSectionScoped()
|
||||||
{
|
{
|
||||||
if (_ptrCritSec)
|
if (_ptrCritSec)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user