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

Unified Diff: webrtc/base/thread.h

Issue 1666863002: Fix race between Thread ctor/dtor and MessageQueueManager registrations. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reverted PS #7, updated comments Created 4 years, 10 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/base/messagequeue.cc ('k') | 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 f91aa56733cb82a880adf6c35ae43114c712fe07..df5a686952f4efe49ea3873a844d245016b8c218 100644
--- a/webrtc/base/thread.h
+++ b/webrtc/base/thread.h
@@ -94,7 +94,13 @@ class Runnable {
class Thread : public MessageQueue {
public:
- explicit Thread(SocketServer* ss = NULL);
+ // Create a new Thread and optionally assign it to the passed SocketServer.
+ // Subclasses that override Clear should pass false for init_queue and call
+ // DoInit() from their constructor to prevent races with the
+ // MessageQueueManager already using the object while the vtable is still
+ // being created.
+ explicit Thread(SocketServer* ss = nullptr, bool init_queue = true);
+
// NOTE: ALL SUBCLASSES OF Thread MUST CALL Stop() IN THEIR DESTRUCTORS (or
// guarantee Stop() is explicitly called before the subclass is destroyed).
// This is required to avoid a data race between the destructor modifying the
@@ -285,7 +291,7 @@ class Thread : public MessageQueue {
class AutoThread : public Thread {
public:
- explicit AutoThread(SocketServer* ss = 0);
+ explicit AutoThread(SocketServer* ss = nullptr);
~AutoThread() override;
private:
@@ -297,10 +303,10 @@ class AutoThread : public Thread {
class ComThread : public Thread {
public:
ComThread() {}
- virtual ~ComThread() { Stop(); }
+ ~ComThread() override { Stop(); }
protected:
- virtual void Run();
+ void Run() override;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(ComThread);
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698