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()
41
41
# Don't emit extended frame info on platforms other than darwin, system
42
42
# backtracer and system debugger are unlikely to support it.
43
43
if (CMAKE_SYSTEM_NAME STREQUAL Darwin )
44
- list (APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS
45
- "-fswift-async-fp=${swift_concurrency_async_fp_mode} " )
46
44
list (APPEND SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS
47
45
"-Xfrontend"
48
46
"-swift-async-frame-pointer=${swift_concurrency_async_fp_mode} " )
49
47
else ()
50
- list (APPEND SWIFT_RUNTIME_CONCURRENCY_C_FLAGS "-fswift-async-fp=never" )
51
48
endif ()
52
49
53
50
add_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)
860
860
861
861
@available( SwiftStdlib 5.5 , * )
862
862
@_silgen_name ( " swift_task_isCancelled " )
863
+ @usableFromInline
863
864
func _taskIsCancelled( _ task: Builtin . NativeObject ) -> Bool
864
865
865
866
@available ( SwiftStdlib 5 . 5 , * )
Original file line number Diff line number Diff line change @@ -50,14 +50,8 @@ extension Task {
50
50
/// There is no way to uncancel a task.
51
51
///
52
52
/// - 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)
61
55
}
62
56
}
63
57
Original file line number Diff line number Diff line change 17
17
@available ( SwiftStdlib 5 . 5 , * )
18
18
@main struct Main {
19
19
static func main( ) async {
20
- let handle = detach {
20
+ let task = Task . detached {
21
21
while ( !Task. isCancelled) { // no need for await here, yay
22
22
print ( " waiting " )
23
23
}
24
24
25
- print ( " done " )
25
+ print ( " inside: Task.isCancelled = \( Task . isCancelled ) " )
26
26
}
27
27
28
- handle . cancel ( )
28
+ task . cancel ( )
29
29
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
32
37
}
33
38
}
You can’t perform that action at this time.
0 commit comments