@@ -43,7 +43,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
43
43
public init ( ) { }
44
44
45
45
public func resolve< Act> ( id: ActorID , as actorType: Act . Type )
46
- throws -> Act ? where Act: DistributedActor {
46
+ throws -> Act ? where Act: DistributedActor , Act . ID == ActorID {
47
47
guard let anyActor = self . activeActorsLock. withLock ( { self . activeActors [ id] } ) else {
48
48
throw LocalTestingDistributedActorSystemError ( message: " Unable to locate id ' \( id) ' locally " )
49
49
}
@@ -54,7 +54,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
54
54
}
55
55
56
56
public func assignID< Act> ( _ actorType: Act . Type ) -> ActorID
57
- where Act: DistributedActor {
57
+ where Act: DistributedActor , Act . ID == ActorID {
58
58
let id = self . idProvider. next ( )
59
59
self . assignedIDsLock. withLock {
60
60
self . assignedIDs. insert ( id)
@@ -63,8 +63,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
63
63
}
64
64
65
65
public func actorReady< Act> ( _ actor : Act )
66
- where Act: DistributedActor ,
67
- Act. ID == ActorID {
66
+ where Act: DistributedActor , Act. ID == ActorID {
68
67
guard self . assignedIDsLock. withLock ( { self . assignedIDs. contains ( actor . id) } ) else {
69
68
fatalError ( " Attempted to mark an unknown actor ' \( actor . id) ' ready " )
70
69
}
@@ -246,10 +245,27 @@ fileprivate class _Lock {
246
245
private let underlying : UnsafeMutablePointer < pthread_mutex_t >
247
246
#endif
248
247
248
+ init ( ) {
249
+ #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
250
+ self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
251
+ self . underlying. initialize ( to: os_unfair_lock ( ) )
252
+ #elseif os(Windows)
253
+ self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
254
+ InitializeSRWLock ( self . underlying)
255
+ #elseif os(WASI)
256
+ // WASI environment has only a single thread
257
+ #else
258
+ self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
259
+ guard pthread_mutex_init ( self . underlying, nil ) == 0 else {
260
+ fatalError ( " pthread_mutex_init failed " )
261
+ }
262
+ #endif
263
+ }
264
+
249
265
deinit {
250
266
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
251
267
// `os_unfair_lock`s do not need to be explicitly destroyed
252
- #elseif os(Windows)
268
+ #elseif os(Windows)
253
269
// `SRWLOCK`s do not need to be explicitly destroyed
254
270
#elseif os(WASI)
255
271
// WASI environment has only a single thread
@@ -265,21 +281,6 @@ fileprivate class _Lock {
265
281
#endif
266
282
}
267
283
268
- init ( ) {
269
- #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
270
- self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
271
- #elseif os(Windows)
272
- self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
273
- InitializeSRWLock ( self . underlying)
274
- #elseif os(WASI)
275
- // WASI environment has only a single thread
276
- #else
277
- self . underlying = UnsafeMutablePointer . allocate ( capacity: 1 )
278
- guard pthread_mutex_init ( self . underlying, nil ) == 0 else {
279
- fatalError ( " pthread_mutex_init failed " )
280
- }
281
- #endif
282
- }
283
284
284
285
@discardableResult
285
286
func withLock< T> ( _ body: ( ) -> T ) -> T {
0 commit comments