Use real Thread in examples/ instead of AutoThread

Bug: webrtc:469327588
Change-Id: I99fa0af31513400270490ee6ee7a4d0a6a6a6964
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/461347
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#47310}
This commit is contained in:
Evan Shrubsole 2026-03-31 12:20:34 +00:00 committed by WebRTC LUCI CQ
parent 6b3d4efe0d
commit 4f399386d9
4 changed files with 17 additions and 7 deletions

View File

@ -820,6 +820,7 @@ if (is_linux || is_chromeos || is_win) {
"../pc:rtc_pc",
"../rtc_base:async_udp_socket",
"../rtc_base:ip_address",
"../rtc_base:net_helper",
"../rtc_base:socket_address",
"../rtc_base:socket_server",
"../rtc_base:threading",

View File

@ -92,7 +92,9 @@ int main(int argc, char* argv[]) {
wnd.Create();
CustomSocketServer socket_server(&wnd);
webrtc::AutoSocketServerThread thread(&socket_server);
std::unique_ptr<webrtc::Thread> thread =
std::make_unique<webrtc::Thread>(&socket_server);
webrtc::ThreadManager::Instance()->SetCurrentThread(thread.get());
webrtc::InitializeSSL();
// Must be constructed after we set the socketserver.
@ -101,7 +103,8 @@ int main(int argc, char* argv[]) {
socket_server.set_client(&client);
socket_server.set_conductor(conductor.get());
thread.Run();
thread->Run();
webrtc::ThreadManager::Instance()->SetCurrentThread(nullptr);
// gtk_main();
wnd.Destroy();

View File

@ -84,7 +84,9 @@ int PASCAL wWinMain(HINSTANCE instance,
int cmd_show) {
webrtc::WinsockInitializer winsock_init;
webrtc::PhysicalSocketServer ss;
webrtc::AutoSocketServerThread main_thread(&ss);
std::unique_ptr<webrtc::Thread> main_thread =
std::make_unique<webrtc::Thread>(&ss);
webrtc::ThreadManager::Instance()->SetCurrentThread(main_thread.get());
WindowsCommandLineArguments win_args;
int argc = win_args.argc();
@ -140,5 +142,6 @@ int PASCAL wWinMain(HINSTANCE instance,
}
webrtc::CleanupSSL();
webrtc::ThreadManager::Instance()->SetCurrentThread(nullptr);
return 0;
}

View File

@ -20,10 +20,10 @@
#include "api/environment/environment_factory.h"
#include "examples/turnserver/read_auth_file.h"
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/port_interface.h"
#include "p2p/test/turn_server.h"
#include "rtc_base/async_udp_socket.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/thread.h"
@ -75,7 +75,9 @@ int main(int argc, char* argv[]) {
const webrtc::Environment env = webrtc::CreateEnvironment();
webrtc::PhysicalSocketServer socket_server;
webrtc::AutoSocketServerThread main(&socket_server);
std::unique_ptr<webrtc::Thread> main =
std::make_unique<webrtc::Thread>(&socket_server);
webrtc::ThreadManager::Instance()->SetCurrentThread(main.get());
std::unique_ptr<webrtc::AsyncUDPSocket> int_socket =
webrtc::AsyncUDPSocket::Create(env, int_addr, socket_server);
if (!int_socket) {
@ -84,7 +86,7 @@ int main(int argc, char* argv[]) {
return 1;
}
webrtc::TurnServer server(env, &main);
webrtc::TurnServer server(env, main.get());
std::fstream auth_file(argv[4], std::fstream::in);
TurnFileAuth auth(auth_file.is_open()
@ -100,6 +102,7 @@ int main(int argc, char* argv[]) {
std::cout << "Listening internally at " << int_addr.ToString() << std::endl;
main.Run();
main->Run();
webrtc::ThreadManager::Instance()->SetCurrentThread(nullptr);
return 0;
}