| 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);
|
| }
|
|
|