@@ -43,7 +43,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
4343 public init ( ) { }
4444
4545 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 {
4747 guard let anyActor = self . activeActorsLock. withLock ( { self . activeActors [ id] } ) else {
4848 throw LocalTestingDistributedActorSystemError ( message: " Unable to locate id ' \( id) ' locally " )
4949 }
@@ -54,7 +54,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
5454 }
5555
5656 public func assignID< Act> ( _ actorType: Act . Type ) -> ActorID
57- where Act: DistributedActor {
57+ where Act: DistributedActor , Act . ID == ActorID {
5858 let id = self . idProvider. next ( )
5959 self . assignedIDsLock. withLock {
6060 self . assignedIDs. insert ( id)
@@ -63,8 +63,7 @@ public final class LocalTestingDistributedActorSystem: DistributedActorSystem, @
6363 }
6464
6565 public func actorReady< Act> ( _ actor : Act )
66- where Act: DistributedActor ,
67- Act. ID == ActorID {
66+ where Act: DistributedActor , Act. ID == ActorID {
6867 guard self . assignedIDsLock. withLock ( { self . assignedIDs. contains ( actor . id) } ) else {
6968 fatalError ( " Attempted to mark an unknown actor ' \( actor . id) ' ready " )
7069 }
@@ -246,10 +245,27 @@ fileprivate class _Lock {
246245 private let underlying : UnsafeMutablePointer < pthread_mutex_t >
247246 #endif
248247
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+
249265 deinit {
250266 #if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
251267 // `os_unfair_lock`s do not need to be explicitly destroyed
252- #elseif os(Windows)
268+ #elseif os(Windows)
253269 // `SRWLOCK`s do not need to be explicitly destroyed
254270 #elseif os(WASI)
255271 // WASI environment has only a single thread
@@ -265,21 +281,6 @@ fileprivate class _Lock {
265281 #endif
266282 }
267283
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- }
283284
284285 @discardableResult
285286 func withLock< T> ( _ body: ( ) -> T ) -> T {
0 commit comments