зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1766646 - Vendor libwebrtc from 7284bd4dab
Upstream commit: https://webrtc.googlesource.com/src/+/7284bd4dabe543b288d0e629c9c1a0936cfb3d4d Use GCD instead of Detached Thread in Async Resolver when on MacOS/iOS The advantage is that GCD maintains the internal thread pool and spawns threads when needed. I would expect the behavior to be almost identical to creating a thread using PlatformThread. Bug: webrtc:13237 Change-Id: Ie4406b5d128c244f66a73830d5a27f2d8fd88549 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234300 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Byoungchan Lee <daniel.l@hpcnt.com> Cr-Commit-Position: refs/heads/main@{#35165}
This commit is contained in:
Родитель
a272f3e42f
Коммит
1245d11304
|
@ -9033,3 +9033,6 @@ bcef6e1859
|
|||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
40abb7d8ff
|
||||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src MOZ_LIBWEBRTC_COMMIT=mjfdev bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
7284bd4dab
|
||||
|
|
|
@ -6030,3 +6030,5 @@ libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwe
|
|||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-06-10T22:11:44.066921.
|
||||
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
|
||||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-06-10T22:16:04.651641.
|
||||
# python3 vendor-libwebrtc.py --from-local /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src --commit mjfdev libwebrtc
|
||||
libwebrtc updated from /home/mfroman/git-checkouts/trial-webrtc-builds/moz-libwebrtc-checkout/src commit mjfdev on 2022-06-10T22:16:46.017560.
|
||||
|
|
|
@ -542,7 +542,10 @@ if (rtc_enable_libevent) {
|
|||
|
||||
if (is_mac || is_ios) {
|
||||
rtc_library("rtc_task_queue_gcd") {
|
||||
visibility = [ "../api/task_queue:default_task_queue_factory" ]
|
||||
visibility = [
|
||||
":threading",
|
||||
"../api/task_queue:default_task_queue_factory",
|
||||
]
|
||||
sources = [
|
||||
"task_queue_gcd.cc",
|
||||
"task_queue_gcd.h",
|
||||
|
@ -834,7 +837,10 @@ rtc_library("threading") {
|
|||
deps += [ ":win32" ]
|
||||
}
|
||||
if (is_mac || is_ios) {
|
||||
deps += [ "system:cocoa_threading" ]
|
||||
deps += [
|
||||
":rtc_task_queue_gcd",
|
||||
"system:cocoa_threading",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "rtc_base/third_party/sigslot/sigslot.h" // for signal_with_thread...
|
||||
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
#include "rtc_base/task_queue_gcd.h"
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
int ResolveHostname(const std::string& hostname,
|
||||
|
@ -123,7 +127,7 @@ void AsyncResolver::Start(const SocketAddress& addr) {
|
|||
RTC_DCHECK_RUN_ON(&sequence_checker_);
|
||||
RTC_DCHECK(!destroy_called_);
|
||||
addr_ = addr;
|
||||
PlatformThread::SpawnDetached(
|
||||
auto thread_function =
|
||||
[this, addr, caller_task_queue = webrtc::TaskQueueBase::Current(),
|
||||
state = state_] {
|
||||
std::vector<IPAddress> addresses;
|
||||
|
@ -146,8 +150,13 @@ void AsyncResolver::Start(const SocketAddress& addr) {
|
|||
}
|
||||
}));
|
||||
}
|
||||
},
|
||||
"AsyncResolver");
|
||||
};
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
webrtc::PostTaskToGlobalQueue(
|
||||
webrtc::ToQueuedTask(std::move(thread_function)));
|
||||
#else
|
||||
PlatformThread::SpawnDetached(std::move(thread_function), "AsyncResolver");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AsyncResolver::GetResolvedAddress(int family, SocketAddress* addr) const {
|
||||
|
|
|
@ -145,10 +145,24 @@ class TaskQueueGcdFactory final : public TaskQueueFactory {
|
|||
}
|
||||
};
|
||||
|
||||
// static
|
||||
void GlobalGcdRunTask(void* context) {
|
||||
std::unique_ptr<QueuedTask> task(static_cast<QueuedTask*>(context));
|
||||
task->Run();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::unique_ptr<TaskQueueFactory> CreateTaskQueueGcdFactory() {
|
||||
return std::make_unique<TaskQueueGcdFactory>();
|
||||
}
|
||||
|
||||
void PostTaskToGlobalQueue(std::unique_ptr<QueuedTask> task,
|
||||
TaskQueueFactory::Priority priority) {
|
||||
dispatch_queue_global_t global_queue =
|
||||
dispatch_get_global_queue(TaskQueuePriorityToGCD(priority), 0);
|
||||
QueuedTask* context = task.release();
|
||||
dispatch_async_f(global_queue, context, &GlobalGcdRunTask);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace webrtc {
|
|||
|
||||
std::unique_ptr<TaskQueueFactory> CreateTaskQueueGcdFactory();
|
||||
|
||||
// Post a task into the system-defined global concurrent queue.
|
||||
void PostTaskToGlobalQueue(
|
||||
std::unique_ptr<QueuedTask> task,
|
||||
TaskQueueFactory::Priority priority = TaskQueueFactory::Priority::NORMAL);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // RTC_BASE_TASK_QUEUE_GCD_H_
|
||||
|
|
Загрузка…
Ссылка в новой задаче