mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Remove a function for posting tasks to the global queue on MacOS/iOS and make it private.
Since `PostTaskToGlobalQueue` is somewhat different from other TaskQueue APIs, there are concerns that it should not be a public API. Remove this from task_queue_gcd.h and make it a private static function of AsyncResolver. Bug: webrtc:13237 Change-Id: Ib4aff296f894a4f3b051969d176369e13a10088f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234900 Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Byoungchan Lee <daniel.l@hpcnt.com> Cr-Commit-Position: refs/heads/main@{#35236}
This commit is contained in:
parent
d7dd0aa9ee
commit
08438fcd9a
4 changed files with 24 additions and 30 deletions
|
@ -542,10 +542,7 @@ if (rtc_enable_libevent) {
|
|||
|
||||
if (is_mac || is_ios) {
|
||||
rtc_library("rtc_task_queue_gcd") {
|
||||
visibility = [
|
||||
":threading",
|
||||
"../api/task_queue:default_task_queue_factory",
|
||||
]
|
||||
visibility = [ "../api/task_queue:default_task_queue_factory" ]
|
||||
sources = [
|
||||
"task_queue_gcd.cc",
|
||||
"task_queue_gcd.h",
|
||||
|
@ -835,10 +832,7 @@ rtc_library("threading") {
|
|||
deps += [ ":win32" ]
|
||||
}
|
||||
if (is_mac || is_ios) {
|
||||
deps += [
|
||||
":rtc_task_queue_gcd",
|
||||
"system:cocoa_threading",
|
||||
]
|
||||
deps += [ "system:cocoa_threading" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,31 @@
|
|||
#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"
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
namespace {
|
||||
|
||||
void GlobalGcdRunTask(void* context) {
|
||||
std::unique_ptr<webrtc::QueuedTask> task(
|
||||
static_cast<webrtc::QueuedTask*>(context));
|
||||
task->Run();
|
||||
}
|
||||
|
||||
// Post a task into the system-defined global concurrent queue.
|
||||
void PostTaskToGlobalQueue(std::unique_ptr<webrtc::QueuedTask> task) {
|
||||
dispatch_queue_global_t global_queue =
|
||||
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
webrtc::QueuedTask* context = task.release();
|
||||
dispatch_async_f(global_queue, context, &GlobalGcdRunTask);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
int ResolveHostname(const std::string& hostname,
|
||||
int family,
|
||||
std::vector<IPAddress>* addresses) {
|
||||
|
@ -152,8 +172,7 @@ void AsyncResolver::Start(const SocketAddress& addr) {
|
|||
}
|
||||
};
|
||||
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||
webrtc::PostTaskToGlobalQueue(
|
||||
webrtc::ToQueuedTask(std::move(thread_function)));
|
||||
PostTaskToGlobalQueue(webrtc::ToQueuedTask(std::move(thread_function)));
|
||||
#else
|
||||
PlatformThread::SpawnDetached(std::move(thread_function), "AsyncResolver");
|
||||
#endif
|
||||
|
|
|
@ -145,24 +145,10 @@ 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,11 +19,6 @@ 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_
|
||||
|
|
Loading…
Reference in a new issue