mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Stop using SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY under SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY (#62735)
Using single-threaded concurrency was a temporary solution, now that the task-to-thread model actually supports multiple threads, let's switch off of it. Instead, let's introduce a "global executor none" option (implicitly set under the task-to-thread model) to denote that the concurrency model is not using a global executor. rdar://99448771
This commit is contained in:
committed by
GitHub
parent
f407389a4a
commit
e9d1d3096a
@@ -18,6 +18,10 @@
|
||||
#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
|
||||
#include <dispatch/swift_concurrency_private.h>
|
||||
|
||||
#if SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
|
||||
#error Cannot use task-to-thread model with priority escalation
|
||||
#endif
|
||||
|
||||
// Provide wrappers with runtime checks to make sure that the dispatch functions
|
||||
// are only called on OS-es where they are supported
|
||||
static inline dispatch_thread_override_info_s
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
|
||||
#if SWIFT_HAS_VOUCHERS
|
||||
|
||||
#if SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
|
||||
#error Cannot use task-to-thread model with vouchers
|
||||
#endif
|
||||
|
||||
#if SWIFT_HAS_VOUCHER_HEADER
|
||||
|
||||
#else
|
||||
|
||||
@@ -180,6 +180,19 @@ if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "singlethreaded"
|
||||
message(SEND_ERROR "Cannot enable the single-threaded global executor without enabling SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY")
|
||||
endif()
|
||||
|
||||
if(SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY)
|
||||
if(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY)
|
||||
message(SEND_ERROR "Cannot use the single-threaded concurrency with task-to-thread concurrency model")
|
||||
endif()
|
||||
if(NOT "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "none")
|
||||
message(SEND_ERROR "Task-to-thread concurrency model requires no global executor")
|
||||
endif()
|
||||
else()
|
||||
if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "none")
|
||||
message(SEND_ERROR "Only task-to-thread concurrency model is usable with no global executor")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
swift_create_stdlib_targets("swift-stdlib" "" TRUE)
|
||||
if(SWIFT_STDLIB_ENABLE_SIB_TARGETS)
|
||||
swift_create_stdlib_targets("swift-stdlib" "sib" TRUE)
|
||||
|
||||
@@ -197,7 +197,9 @@ option(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY
|
||||
"Build the standard libraries assuming that they will be used in an environment with only a single thread."
|
||||
FALSE)
|
||||
|
||||
if(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY)
|
||||
if(SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY)
|
||||
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default "none")
|
||||
elseif(SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY)
|
||||
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default "singlethreaded")
|
||||
else()
|
||||
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default "dispatch")
|
||||
@@ -205,7 +207,7 @@ endif()
|
||||
|
||||
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR
|
||||
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default}" CACHE STRING
|
||||
"Build the concurrency library to use the given global executor (options: dispatch, singlethreaded, hooked)")
|
||||
"Build the concurrency library to use the given global executor (options: none, dispatch, singlethreaded, hooked)")
|
||||
|
||||
option(SWIFT_STDLIB_OS_VERSIONING
|
||||
"Build stdlib with availability based on OS versions (Darwin only)."
|
||||
|
||||
@@ -283,6 +283,8 @@ static bool isExecutingOnMainThread() {
|
||||
JobPriority swift::swift_task_getCurrentThreadPriority() {
|
||||
#if SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY
|
||||
return JobPriority::UserInitiated;
|
||||
#elif SWIFT_CONCURRENCY_TASK_TO_THREAD_MODEL
|
||||
return JobPriority::Unspecified;
|
||||
#elif defined(__APPLE__)
|
||||
return static_cast<JobPriority>(qos_class_self());
|
||||
#else
|
||||
|
||||
@@ -44,7 +44,8 @@ if("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
|
||||
dispatch)
|
||||
endif()
|
||||
elseif("${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "singlethreaded" OR
|
||||
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "hooked")
|
||||
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "hooked" OR
|
||||
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "none")
|
||||
list(APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
|
||||
"-DSWIFT_CONCURRENCY_ENABLE_DISPATCH=0")
|
||||
else()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// rdar://76038845
|
||||
// REQUIRES: concurrency_runtime
|
||||
// UNSUPPORTED: back_deployment_runtime
|
||||
// UNSUPPORTED: single_threaded_concurrency
|
||||
// UNSUPPORTED: freestanding
|
||||
|
||||
// for sleep
|
||||
#if canImport(Darwin)
|
||||
|
||||
@@ -2544,7 +2544,6 @@ swift-stdlib-has-stdin=0
|
||||
swift-stdlib-has-environ=0
|
||||
swift-stdlib-has-locale=0
|
||||
swift-runtime-static-image-inspection=1
|
||||
swift-stdlib-single-threaded-concurrency=1
|
||||
swift-stdlib-concurrency-tracing=0
|
||||
swift-stdlib-os-versioning=0
|
||||
swift-stdlib-has-commandline=0
|
||||
|
||||
Reference in New Issue
Block a user