From b19582b7dcae41f0ca7ce3eed6900a32dd06f64d Mon Sep 17 00:00:00 2001 From: "mflodman@webrtc.org" Date: Fri, 9 Dec 2011 10:02:16 +0000 Subject: [PATCH] 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 --- .../interface/critical_section_wrapper.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/system_wrappers/interface/critical_section_wrapper.h b/src/system_wrappers/interface/critical_section_wrapper.h index ad31497e76..cfec9ae79d 100644 --- a/src/system_wrappers/interface/critical_section_wrapper.h +++ b/src/system_wrappers/interface/critical_section_wrapper.h @@ -33,18 +33,26 @@ public: 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. class CriticalSectionScoped { public: - CriticalSectionScoped(CriticalSectionWrapper& critsec) - : - _ptrCritSec(&critsec) + // Deprecated, don't add more users of this constructor. + // TODO(mflodman) Remove this version of the constructor when no one is + // using it any longer. + explicit CriticalSectionScoped(CriticalSectionWrapper& critsec) + : _ptrCritSec(&critsec) { _ptrCritSec->Enter(); } + explicit CriticalSectionScoped(CriticalSectionWrapper* critsec) + : _ptrCritSec(critsec) + { + _ptrCritSec->Enter(); + } + ~CriticalSectionScoped() { if (_ptrCritSec)