@@ -20,6 +20,7 @@ import FakeDistributedActorSystems
20
20
21
21
typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem
22
22
23
+ @available ( SwiftStdlib 6 . 0 , * )
23
24
protocol PlainWorker {
24
25
associatedtype WorkItem : Sendable & Codable
25
26
associatedtype WorkResult : Sendable & Codable
@@ -28,7 +29,9 @@ protocol PlainWorker {
28
29
func asyncThrows( work: WorkItem ) async throws -> WorkResult
29
30
}
30
31
31
- protocol DistributedWorker : DistributedActor where ActorSystem == DefaultDistributedActorSystem {
32
+ @Resolvable
33
+ @available ( SwiftStdlib 6 . 0 , * )
34
+ protocol DistributedWorker < WorkItem, WorkResult> : DistributedActor where ActorSystem == DefaultDistributedActorSystem {
32
35
associatedtype WorkItem : Sendable & Codable
33
36
associatedtype WorkResult : Sendable & Codable
34
37
@@ -49,6 +52,7 @@ protocol DistributedWorker: DistributedActor where ActorSystem == DefaultDistrib
49
52
func asyncThrowsReq_witnessDistributed_asyncThrows( work: WorkItem ) async throws -> WorkResult
50
53
}
51
54
55
+ @available ( SwiftStdlib 6 . 0 , * )
52
56
distributed actor ThePlainWorker : PlainWorker {
53
57
typealias ActorSystem = DefaultDistributedActorSystem
54
58
typealias WorkItem = String
@@ -59,6 +63,7 @@ distributed actor ThePlainWorker: PlainWorker {
59
63
}
60
64
}
61
65
66
+ @available ( SwiftStdlib 6 . 0 , * )
62
67
distributed actor TheWorker : DistributedWorker {
63
68
typealias ActorSystem = DefaultDistributedActorSystem
64
69
typealias WorkItem = String
@@ -105,6 +110,7 @@ distributed actor TheWorker: DistributedWorker {
105
110
106
111
}
107
112
113
+ @available ( SwiftStdlib 6 . 0 , * )
108
114
func test_generic( system: DefaultDistributedActorSystem ) async throws {
109
115
let localW = TheWorker ( actorSystem: system)
110
116
let remoteW = try ! TheWorker . resolve ( id: localW. id, using: system)
@@ -218,6 +224,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
218
224
// distributedness of those witnesses never actually is used remotely, but at
219
225
// least check we invoke the right methods.
220
226
227
+ @available ( SwiftStdlib 6 . 0 , * )
221
228
func call_requirement_witnessedByDistributed_sync< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
222
229
try await w. whenLocal { __secretlyKnownToBeLocal in
223
230
try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_sync ( work: " Hello " )
@@ -231,6 +238,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
231
238
}
232
239
print ( " ==== ---------------------------------------------------------------- " )
233
240
241
+ @available ( SwiftStdlib 6 . 0 , * )
234
242
func call_requirement_witnessedByDistributed_async< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
235
243
try await w. whenLocal { __secretlyKnownToBeLocal in
236
244
try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_async ( work: " Hello " )
@@ -244,6 +252,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
244
252
}
245
253
print ( " ==== ---------------------------------------------------------------- " )
246
254
255
+ @available ( SwiftStdlib 6 . 0 , * )
247
256
func call_requirement_witnessedByDistributed_syncThrows< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
248
257
try await w. whenLocal { __secretlyKnownToBeLocal in
249
258
try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_syncThrows ( work: " Hello " )
@@ -257,6 +266,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
257
266
}
258
267
print ( " ==== ---------------------------------------------------------------- " )
259
268
269
+ @available ( SwiftStdlib 6 . 0 , * )
260
270
func call_requirement_witnessedByDistributed_asyncThrows< W: DistributedWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
261
271
try await w. whenLocal { __secretlyKnownToBeLocal in
262
272
try await __secretlyKnownToBeLocal. asyncThrowsReq_witnessDistributed_asyncThrows ( work: " Hello " )
@@ -271,6 +281,7 @@ func test_generic(system: DefaultDistributedActorSystem) async throws {
271
281
print ( " ==== ---------------------------------------------------------------- " )
272
282
}
273
283
284
+ @available ( SwiftStdlib 6 . 0 , * )
274
285
func test_whenLocal( system: DefaultDistributedActorSystem ) async throws {
275
286
let localW = TheWorker ( actorSystem: system)
276
287
let remoteW = try ! TheWorker . resolve ( id: localW. id, using: system)
@@ -341,6 +352,7 @@ func test_whenLocal(system: DefaultDistributedActorSystem) async throws {
341
352
}
342
353
}
343
354
355
+ @available ( SwiftStdlib 6 . 0 , * )
344
356
func test_generic_plain( system: DefaultDistributedActorSystem ) async throws {
345
357
let localW = ThePlainWorker ( actorSystem: system)
346
358
let remoteW = try ! ThePlainWorker . resolve ( id: localW. id, using: system)
@@ -355,6 +367,7 @@ func test_generic_plain(system: DefaultDistributedActorSystem) async throws {
355
367
}
356
368
print ( " ==== ---------------------------------------------------------------- " )
357
369
370
+ @available ( SwiftStdlib 6 . 0 , * )
358
371
func call_plainWorker< W: PlainWorker > ( w: W ) async throws -> String where W. WorkItem == String , W. WorkResult == String {
359
372
try await w. asyncThrows ( work: " Hello " )
360
373
}
@@ -372,6 +385,7 @@ func test_generic_plain(system: DefaultDistributedActorSystem) async throws {
372
385
}
373
386
}
374
387
388
+ @available ( SwiftStdlib 6 . 0 , * )
375
389
@main struct Main {
376
390
static func main( ) async {
377
391
let system = DefaultDistributedActorSystem ( )
0 commit comments