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

Unified Diff: webrtc/base/thread.cc

Issue 1891293002: Adds clearer function to create rtc::Thread without Physical SocketServer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase; move two Thread constructors to protected Created 4 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
« webrtc/base/thread.h ('K') | « webrtc/base/thread.h ('k') | no next file » | 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 dc8ccdfd4dd1dafd958f487450e254bb7b901693..1caf16a9760c0d6ae2ab8bb3d80e782f3c3bbc67 100644
--- a/webrtc/base/thread.cc
+++ b/webrtc/base/thread.cc
@@ -22,6 +22,7 @@
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
+#include "webrtc/base/nullsocketserver.h"
#include "webrtc/base/platform_thread.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/timeutils.h"
@@ -138,6 +139,10 @@ Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() {
thread_->SetAllowBlockingCalls(previous_state_);
}
+Thread::Thread() : Thread(SocketServer::CreateDefault(), true) {}
+
+Thread::Thread(SocketServer* ss) : Thread(ss, true) {}
+
Thread::Thread(SocketServer* ss, bool init_queue)
: MessageQueue(ss, false),
running_(true, false),
@@ -153,11 +158,36 @@ Thread::Thread(SocketServer* ss, bool init_queue)
}
}
+Thread::Thread(std::unique_ptr<SocketServer> ss, bool init_queue)
+ : MessageQueue(std::move(ss), false),
+ running_(true, false),
+#if defined(WEBRTC_WIN)
+ thread_(NULL),
+ thread_id_(0),
+#endif
+ owned_(true),
+ blocking_calls_allowed_(true) {
+ SetName("Thread", this); // default name
+ if (init_queue) {
+ DoInit();
+ }
+}
+
Thread::~Thread() {
Stop();
DoDestroy();
}
+std::unique_ptr<Thread> Thread::CreateWithSocketServer() {
+ return std::unique_ptr<Thread>(
+ new Thread(SocketServer::CreateDefault(), true));
+}
+
+std::unique_ptr<Thread> Thread::Create() {
+ return std::unique_ptr<Thread>(
+ new Thread(std::unique_ptr<SocketServer>(new NullSocketServer()), true));
+}
+
bool Thread::SleepMs(int milliseconds) {
AssertBlockingIsAllowedOnCurrentThread();
@@ -513,7 +543,7 @@ bool Thread::WrapCurrentWithThreadManager(ThreadManager* thread_manager,
return true;
}
-AutoThread::AutoThread(SocketServer* ss) : Thread(ss) {
+AutoThread::AutoThread() {
if (!ThreadManager::Instance()->CurrentThread()) {
ThreadManager::Instance()->SetCurrentThread(this);
}
« webrtc/base/thread.h ('K') | « webrtc/base/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698