Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(686)

Unified Diff: webrtc/system_wrappers/include/static_instance.h

Issue 2779623002: remove more CriticalSectionWrappers. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/system_wrappers/source/trace_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/system_wrappers/include/static_instance.h
diff --git a/webrtc/system_wrappers/include/static_instance.h b/webrtc/system_wrappers/include/static_instance.h
index 41946d9230d1e53e25ea156067068e10f1cc124b..e9bf81d951ebec749aca5a7d8dc303bbf6b06d84 100644
--- a/webrtc/system_wrappers/include/static_instance.h
+++ b/webrtc/system_wrappers/include/static_instance.h
@@ -13,7 +13,7 @@
#include <assert.h>
-#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
+#include "webrtc/base/criticalsection.h"
#ifdef _WIN32
#include "webrtc/system_wrappers/include/fix_interlocked_exchange_pointer_win.h"
#endif
@@ -40,14 +40,8 @@ static T* GetStaticInstance(CountOperation count_operation) {
static T* volatile instance = NULL;
CreateOperation state = kInstanceExists;
#ifndef _WIN32
- // This memory is staticly allocated once. The application does not try to
- // free this memory. This approach is taken to avoid issues with
- // destruction order for statically allocated memory. The memory will be
- // reclaimed by the OS and memory leak tools will not recognize memory
- // reachable from statics leaked so no noise is added by doing this.
- static CriticalSectionWrapper* crit_sect(
- CriticalSectionWrapper::CreateCriticalSection());
- CriticalSectionScoped lock(crit_sect);
+ rtc::CriticalSection crit_sect;
+ rtc::CritScope lock(&crit_sect);
if (count_operation ==
kAddRefNoCreate && instance_count == 0) {
@@ -77,13 +71,13 @@ static T* GetStaticInstance(CountOperation count_operation) {
// since the thread owned by the tracing class also traces).
// TODO(hellner): this is a bit out of place but here goes, de-couple
// thread implementation with trace implementation.
- crit_sect->Leave();
+ crit_sect.Leave();
if (old_instance) {
delete old_instance;
}
// Re-acquire the lock since the scoped critical section will release
// it.
- crit_sect->Enter();
+ crit_sect.Enter();
return NULL;
}
#else // _WIN32
« no previous file with comments | « webrtc/modules/video_coding/video_coding_impl.cc ('k') | webrtc/system_wrappers/source/trace_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698