@@ -60,9 +60,11 @@ final class AsyncIO: @unchecked Sendable {
6060 internal init ( ) {
6161 var maybeSetupError : SubprocessError ? = nil
6262 // Create the the completion port
63- guard let ioCompletionPort = CreateIoCompletionPort (
64- INVALID_HANDLE_VALUE, nil , 0 , 0
65- ) , ioCompletionPort != INVALID_HANDLE_VALUE else {
63+ guard
64+ let ioCompletionPort = CreateIoCompletionPort (
65+ INVALID_HANDLE_VALUE, nil , 0 , 0
66+ ) , ioCompletionPort != INVALID_HANDLE_VALUE
67+ else {
6668 let error = SubprocessError (
6769 code: . init( . asyncIOFailed( " CreateIoCompletionPort failed " ) ) ,
6870 underlyingError: . init( rawValue: GetLastError ( ) )
@@ -86,50 +88,12 @@ final class AsyncIO: @unchecked Sendable {
8688 }
8789 }
8890
89- // Monitor loop
90- while true {
91- var bytesTransferred : DWORD = 0
92- var targetFileDescriptor : UInt64 = 0
93- var overlapped : LPOVERLAPPED ? = nil
9491 // Monitor loop
9592 while true {
9693 var bytesTransferred : DWORD = 0
9794 var targetFileDescriptor : UInt64 = 0
9895 var overlapped : LPOVERLAPPED ? = nil
9996
100- let monitorResult = GetQueuedCompletionStatus (
101- context. ioCompletionPort,
102- & bytesTransferred,
103- & targetFileDescriptor,
104- & overlapped,
105- INFINITE
106- )
107- if !monitorResult {
108- let lastError = GetLastError ( )
109- if lastError == ERROR_BROKEN_PIPE {
110- // We finished reading the handle. Signal EOF by
111- // finishing the stream.
112- // NOTE: here we deliberately leave now unused continuation
113- // in the store. Windows does not offer an API to remove a
114- // HANDLE from an IOCP port, therefore we leave the registration
115- // to signify the HANDLE has already been resisted.
116- let continuation = _registration. withLock { store -> SignalStream . Continuation ? in
117- if let continuation = store [ targetFileDescriptor] {
118- return continuation
119- }
120- return nil
121- }
122- continuation? . finish ( )
123- continue
124- } else {
125- let error = SubprocessError (
126- code: . init( . asyncIOFailed( " GetQueuedCompletionStatus failed " ) ) ,
127- underlyingError: . init( rawValue: lastError)
128- )
129- reportError ( error)
130- break
131- }
132- }
13397 let monitorResult = GetQueuedCompletionStatus (
13498 context. ioCompletionPort,
13599 & bytesTransferred,
0 commit comments