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

Unified Diff: webrtc/base/thread.h

Issue 2833993003: Move autowrap from ThreadManager constructor to Thread::Current. (Closed)
Patch Set: Limit autowrap to main thread only. New method ThreadManager::IsMainThread. 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.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/thread.h
diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h
index 01c80501c8010a2cfd2f39230abf1f9af28f3f34..e9bb3249ea809f9b963d58a3a65d932a3e2d3be7 100644
--- a/webrtc/base/thread.h
+++ b/webrtc/base/thread.h
@@ -23,6 +23,7 @@
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/event.h"
#include "webrtc/base/messagequeue.h"
+#include "webrtc/base/platform_thread_types.h"
#if defined(WEBRTC_WIN)
#include "webrtc/base/win32.h"
@@ -36,9 +37,7 @@ class ThreadManager {
public:
static const int kForever = -1;
- ThreadManager();
- ~ThreadManager();
-
+ // Singleton, constructor and destructor are private.
static ThreadManager* Instance();
Thread* CurrentThread();
@@ -60,7 +59,12 @@ class ThreadManager {
Thread *WrapCurrentThread();
void UnwrapCurrentThread();
+ bool IsMainThread();
+
private:
+ ThreadManager();
+ ~ThreadManager();
+
#if defined(WEBRTC_POSIX)
pthread_key_t key_;
#endif
@@ -69,6 +73,9 @@ class ThreadManager {
DWORD key_;
#endif
+ // The thread to potentially autowrap.
+ PlatformThreadRef main_thread_ref_;
+
RTC_DISALLOW_COPY_AND_ASSIGN(ThreadManager);
};
@@ -123,9 +130,7 @@ class LOCKABLE Thread : public MessageQueue {
const bool previous_state_;
};
- bool IsCurrent() const {
- return Current() == this;
- }
+ bool IsCurrent() const;
// Sleeps the calling thread for the specified number of milliseconds, during
// which time no processing is performed. Returns false if sleeping was
« no previous file with comments | « no previous file | webrtc/base/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698