Reland "Delete NO_MAIN_THREAD_WRAPPING preprocessor define."
This is a reland of 0f78c6b28dbc0c9caa555ce89ce91b0f08c510ea Original change's description: > Delete NO_MAIN_THREAD_WRAPPING preprocessor define. > > Since many tests rely on rtc::Thread::Current(), add an > explicit rtc::AutoThread in the main() function used by tests. > > Bug: webrtc:9714 > Change-Id: Id82121967c9621fe1c2945846009c48139fa57da > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/39680 > Reviewed-by: Kári Helgason <kthelgason@webrtc.org> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#28000} Bug: webrtc:9714 Change-Id: I85f8a7058387771a31c099b1080ae53f1648dce6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137513 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35932}
This commit is contained in:
parent
1af9022732
commit
98d26df5b7
@ -14,10 +14,6 @@ if (is_android) {
|
||||
import("//build/config/android/rules.gni")
|
||||
}
|
||||
|
||||
config("threading_chromium_config") {
|
||||
defines = [ "NO_MAIN_THREAD_WRAPPING" ]
|
||||
}
|
||||
|
||||
if (!rtc_build_ssl) {
|
||||
config("external_ssl_library") {
|
||||
assert(rtc_ssl_root != "",
|
||||
@ -768,10 +764,6 @@ rtc_source_set("socket_server") {
|
||||
rtc_library("threading") {
|
||||
visibility = [ "*" ]
|
||||
|
||||
if (build_with_chromium) {
|
||||
public_configs = [ ":threading_chromium_config" ]
|
||||
}
|
||||
|
||||
sources = [
|
||||
"async_resolver.cc",
|
||||
"async_resolver.h",
|
||||
|
||||
@ -255,19 +255,11 @@ Thread* Thread::Current() {
|
||||
ThreadManager* manager = ThreadManager::Instance();
|
||||
Thread* thread = manager->CurrentThread();
|
||||
|
||||
#ifndef NO_MAIN_THREAD_WRAPPING
|
||||
// Only autowrap the thread which instantiated the ThreadManager.
|
||||
if (!thread && manager->IsMainThread()) {
|
||||
thread = new Thread(CreateDefaultSocketServer());
|
||||
thread->WrapCurrentWithThreadManager(manager, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
#if defined(WEBRTC_POSIX)
|
||||
ThreadManager::ThreadManager() : main_thread_ref_(CurrentThreadRef()) {
|
||||
ThreadManager::ThreadManager() {
|
||||
#if defined(WEBRTC_MAC)
|
||||
InitCocoaMultiThreading();
|
||||
#endif
|
||||
@ -284,8 +276,7 @@ void ThreadManager::SetCurrentThreadInternal(Thread* thread) {
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
ThreadManager::ThreadManager()
|
||||
: key_(TlsAlloc()), main_thread_ref_(CurrentThreadRef()) {}
|
||||
ThreadManager::ThreadManager() : key_(TlsAlloc()) {}
|
||||
|
||||
Thread* ThreadManager::CurrentThread() {
|
||||
return static_cast<Thread*>(TlsGetValue(key_));
|
||||
@ -341,10 +332,6 @@ void ThreadManager::UnwrapCurrentThread() {
|
||||
}
|
||||
}
|
||||
|
||||
bool ThreadManager::IsMainThread() {
|
||||
return IsThreadRefEqual(CurrentThreadRef(), main_thread_ref_);
|
||||
}
|
||||
|
||||
Thread::ScopedDisallowBlockingCalls::ScopedDisallowBlockingCalls()
|
||||
: thread_(Thread::Current()),
|
||||
previous_state_(thread_->SetAllowBlockingCalls(false)) {}
|
||||
|
||||
@ -141,8 +141,6 @@ class RTC_EXPORT ThreadManager {
|
||||
Thread* WrapCurrentThread();
|
||||
void UnwrapCurrentThread();
|
||||
|
||||
bool IsMainThread();
|
||||
|
||||
#if RTC_DCHECK_IS_ON
|
||||
// Registers that a Send operation is to be performed between `source` and
|
||||
// `target`, while checking that this does not cause a send cycle that could
|
||||
@ -188,9 +186,6 @@ class RTC_EXPORT ThreadManager {
|
||||
#if defined(WEBRTC_WIN)
|
||||
const DWORD key_;
|
||||
#endif
|
||||
|
||||
// The thread to potentially autowrap.
|
||||
const PlatformThreadRef main_thread_ref_;
|
||||
};
|
||||
|
||||
// WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread().
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user