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