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

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: 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
« no previous file with comments | « 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..7cbc9728417666dfce4faa5a7b94fe8840c64591 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,7 +139,9 @@ Thread::ScopedDisallowBlockingCalls::~ScopedDisallowBlockingCalls() {
thread_->SetAllowBlockingCalls(previous_state_);
}
-Thread::Thread(SocketServer* ss, bool init_queue)
+Thread::Thread() : Thread(SocketServer::CreateDefault()) {}
+
+Thread::Thread(SocketServer* ss)
: MessageQueue(ss, false),
running_(true, false),
#if defined(WEBRTC_WIN)
@@ -148,9 +151,20 @@ Thread::Thread(SocketServer* ss, bool init_queue)
owned_(true),
blocking_calls_allowed_(true) {
SetName("Thread", this); // default name
- if (init_queue) {
- DoInit();
- }
+ DoInit();
+}
+
+Thread::Thread(std::unique_ptr<SocketServer> ss)
+ : 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
+ DoInit();
}
Thread::~Thread() {
@@ -158,6 +172,15 @@ Thread::~Thread() {
DoDestroy();
}
+std::unique_ptr<Thread> Thread::CreateWithSocketServer() {
+ return std::unique_ptr<Thread>(new Thread(SocketServer::CreateDefault()));
+}
+
+std::unique_ptr<Thread> Thread::Create() {
+ return std::unique_ptr<Thread>(
+ new Thread(std::unique_ptr<SocketServer>(new NullSocketServer())));
+}
+
bool Thread::SleepMs(int milliseconds) {
AssertBlockingIsAllowedOnCurrentThread();
@@ -513,7 +536,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);
}
« no previous file with comments | « webrtc/base/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698