File tree Expand file tree Collapse file tree 4 files changed +13
-16
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 4 files changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -41,13 +41,10 @@ endif()
4141# Don't emit extended frame info on platforms other than darwin, system
4242# backtracer and system debugger are unlikely to support it.
4343if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
44- list (APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
45- "-fswift-async-fp=${swift_concurrency_async_fp_mode} " )
4644 list (APPEND SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS
4745 "-Xfrontend"
4846 "-swift-async-frame-pointer=${swift_concurrency_async_fp_mode} " )
4947else ()
50- list (APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS "-fswift-async-fp=never" )
5148endif ()
5249
5350add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
Original file line number Diff line number Diff line change @@ -860,6 +860,7 @@ func _taskCancel(_ task: Builtin.NativeObject)
860860
861861@available( SwiftStdlib 5.5 , * )
862862@_silgen_name ( " swift_task_isCancelled " )
863+ @usableFromInline
863864func _taskIsCancelled( _ task: Builtin . NativeObject ) -> Bool
864865
865866@available ( SwiftStdlib 5 . 5 , * )
Original file line number Diff line number Diff line change @@ -50,14 +50,8 @@ extension Task {
5050 /// There is no way to uncancel a task.
5151 ///
5252 /// - SeeAlso: `checkCancellation()`
53- public var isCancelled : Bool {
54- withUnsafeCurrentTask { task in
55- guard let task = task else {
56- return false
57- }
58-
59- return _taskIsCancelled ( task. _task)
60- }
53+ @_transparent public var isCancelled : Bool {
54+ _taskIsCancelled ( _task)
6155 }
6256}
6357
Original file line number Diff line number Diff line change 1717@available ( SwiftStdlib 5 . 5 , * )
1818@main struct Main {
1919 static func main( ) async {
20- let handle = detach {
20+ let task = Task . detached {
2121 while ( !Task. isCancelled) { // no need for await here, yay
2222 print ( " waiting " )
2323 }
2424
25- print ( " done " )
25+ print ( " inside: Task.isCancelled = \( Task . isCancelled ) " )
2626 }
2727
28- handle . cancel ( )
28+ task . cancel ( )
2929
30- // CHECK: done
31- await handle. get ( )
30+ await task. value
31+ print ( " outside: task.isCancelled = \( task. isCancelled) " )
32+ print ( " outside: Task.isCancelled = \( Task . isCancelled) " )
33+
34+ // CHECK-DAG: inside: Task.isCancelled = true
35+ // CHECK-DAG: outside: task.isCancelled = true
36+ // CHECK-DAG: outside: Task.isCancelled = false
3237 }
3338}
You can’t perform that action at this time.
0 commit comments