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

Unified Diff: webrtc/base/thread.cc

Issue 2833993003: Move autowrap from ThreadManager constructor to Thread::Current. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | webrtc/base/thread_darwin.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/thread.cc
diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc
index 66542bb3d90712cfc927d1d9f225e2055aacaddf..f48f0f78be24dd8af4aac0b3be70d3754525cc81 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -31,23 +31,24 @@ ThreadManager* ThreadManager::Instance() {
return &thread_manager;
}
+ThreadManager::~ThreadManager() {
+ // By above RTC_DEFINE_STATIC_LOCAL.
+ RTC_NOTREACHED() << "ThreadManager should never be destructed.";
Taylor Brandstetter 2017/04/21 09:54:28 But it has a public constructor/destructor, so a n
nisse-webrtc 2017/04/21 11:06:07 I'd prefer to not add the bookkeeping needed to un
Taylor Brandstetter 2017/04/21 11:32:54 Let's try making the constructor/destructor privat
+}
+
// static
Thread* Thread::Current() {
+#ifdef NO_MAIN_THREAD_WRAPPING
return ThreadManager::Instance()->CurrentThread();
+#else
+ return ThreadManager::Instance()->WrapCurrentThread();
+#endif
}
#if defined(WEBRTC_POSIX)
#if !defined(WEBRTC_MAC)
ThreadManager::ThreadManager() {
pthread_key_create(&key_, nullptr);
-#ifndef NO_MAIN_THREAD_WRAPPING
- WrapCurrentThread();
-#endif
-}
-
-ThreadManager::~ThreadManager() {
- UnwrapCurrentThread();
- pthread_key_delete(key_);
}
#endif
@@ -63,14 +64,6 @@ void ThreadManager::SetCurrentThread(Thread *thread) {
#if defined(WEBRTC_WIN)
ThreadManager::ThreadManager() {
key_ = TlsAlloc();
-#ifndef NO_MAIN_THREAD_WRAPPING
- WrapCurrentThread();
-#endif
-}
-
-ThreadManager::~ThreadManager() {
- UnwrapCurrentThread();
- TlsFree(key_);
}
Thread *ThreadManager::CurrentThread() {
« no previous file with comments | « no previous file | webrtc/base/thread_darwin.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698