@@ -60,9 +60,11 @@ final class AsyncIO: @unchecked Sendable {
60
60
internal init ( ) {
61
61
var maybeSetupError : SubprocessError ? = nil
62
62
// 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 {
66
68
let error = SubprocessError (
67
69
code: . init( . asyncIOFailed( " CreateIoCompletionPort failed " ) ) ,
68
70
underlyingError: . init( rawValue: GetLastError ( ) )
@@ -86,50 +88,12 @@ final class AsyncIO: @unchecked Sendable {
86
88
}
87
89
}
88
90
89
- // Monitor loop
90
- while true {
91
- var bytesTransferred : DWORD = 0
92
- var targetFileDescriptor : UInt64 = 0
93
- var overlapped : LPOVERLAPPED ? = nil
94
91
// Monitor loop
95
92
while true {
96
93
var bytesTransferred : DWORD = 0
97
94
var targetFileDescriptor : UInt64 = 0
98
95
var overlapped : LPOVERLAPPED ? = nil
99
96
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
- }
133
97
let monitorResult = GetQueuedCompletionStatus (
134
98
context. ioCompletionPort,
135
99
& bytesTransferred,
0 commit comments