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 Job) {
48
+ public init( _ job: __owned Job) { // 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 @@ -51,3 +51,15 @@ final class NewExecutor: SerialExecutor {
51
51
UnownedSerialExecutor ( ordinary: self )
52
52
}
53
53
}
54
+
55
+ // Good impl, but missing the ownership keyword
56
+ final class MissingOwnership : SerialExecutor {
57
+ func enqueue( _ job: ExecutorJob ) { } // expected-error{{noncopyable parameter must specify its ownership}}
58
+ // expected-note@-1{{add 'borrowing' for an immutable reference}}
59
+ // expected-note@-2{{add 'inout' for a mutable reference}}
60
+ // expected-note@-3{{add 'consuming' to take the value from the caller}}
61
+
62
+ func asUnownedSerialExecutor( ) -> UnownedSerialExecutor {
63
+ UnownedSerialExecutor ( ordinary: self )
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments