File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ public struct UnownedJob: Sendable {
45
45
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
46
46
/// Create an `UnownedJob` whose lifetime must be managed carefully until it is run exactly once.
47
47
@available ( SwiftStdlib 5 . 9 , * )
48
- public init( _ job: __owned ExecutorJob) {
48
+ public init( _ job: __owned ExecutorJob) { // must remain '__owned' in order to not break ABI
49
49
self . context = job. context
50
50
}
51
51
#endif // !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
Original file line number Diff line number Diff line change @@ -78,3 +78,15 @@ final class NewExecutor: SerialExecutor {
78
78
UnownedSerialExecutor ( ordinary: self )
79
79
}
80
80
}
81
+
82
+ // Good impl, but missing the ownership keyword
83
+ final class MissingOwnership : SerialExecutor {
84
+ func enqueue( _ job: ExecutorJob ) { } // expected-error{{noncopyable parameter must specify its ownership}}
85
+ // expected-note@-1{{add 'borrowing' for an immutable reference}}
86
+ // expected-note@-2{{add 'inout' for a mutable reference}}
87
+ // expected-note@-3{{add 'consuming' to take the value from the caller}}
88
+
89
+ func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
90
+ UnownedSerialExecutor ( ordinary: self )
91
+ }
92
+ }
You can’t perform that action at this time.
0 commit comments