Debian Codegraph @

src/kj/async-io.c++

raw symbols SCIP
1 // Copyright (c) 2013-2017 Sandstorm Development Group, Inc. and contributorscxx . . $ `<file>/src/kj/async-io.c++`/
2 // Licensed under the MIT License:
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21
22 #if _WIN32
23 // Request Vista-level APIs.
24 #include <kj/win32-api-version.h>
25 #endif
26
27 #include "async-io.h"cxx . . $ `<file>/src/kj/async-io.h`/
28 #include "async-io-internal.h"cxx . . $ `<file>/src/kj/async-io-internal.h`/
29 #include "debug.h"cxx . . $ `<file>/src/kj/debug.h`/
30 #include "vector.h"cxx . . $ `<file>/src/kj/vector.h`/
31 #include "io.h"cxx . . $ `<file>/src/kj/io.h`/
32 #include "one-of.h"cxx . . $ `<file>/src/kj/one-of.h`/
33 #include <deque>
34 #include <kj/filesystem.h>cxx . . $ `<file>/src/kj/filesystem.h`/
35
36 #if _WIN32
37 #include <winsock2.h>
38 #include <ws2ipdef.h>
39 #include <ws2tcpip.h>
40 #include <kj/windows-sanity.h>
41 #define inet_pton InetPtonA
42 #define inet_ntop InetNtopA
43 #include <io.h>
44 #define dup _dup
45 #else
46 #include <sys/socket.h>
47 #include <arpa/inet.h>
48 #include <netinet/in.h>
49 #include <sys/un.h>
50 #include <unistd.h>
51 #endif
52
53 namespace kjcxx . . $ kj/ {
54
55 Promisecxx . . $ kj/Promise#<void> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::readcxx . . $ kj/AsyncInputStream#read(345d56efc16bea2d).(void* buffer, size_t bytes) {
56 return readcxx . . $ kj/AsyncInputStream#read(1d893319628a2258).(buffer, bytes, bytes).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](size_t) {});
57 }
58
59 Promisecxx . . $ kj/Promise#<size_t> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::readcxx . . $ kj/AsyncInputStream#read(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) {
60 return tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([=](size_t result) {
61 if (result >= minBytes) {
62 return result;
63 } else {
64 kjcxx . . $ kj/::throwRecoverableExceptioncxx . . $ kj/throwRecoverableException(6529c6cadc6e9b51).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "stream disconnected prematurely"));
65 // Pretend we read zeros from the input.
66 memset(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer) + result, 0, minBytes - result);
67 return minBytes;
68 }
69 });
70 }
71
72 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::tryGetLengthcxx . . $ kj/AsyncInputStream#tryGetLength(b0ae5156aeb9187c).() { return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).; }
73
74 void AsyncInputStreamcxx . . $ kj/AsyncInputStream#::registerAncillaryMessageHandlercxx . . $ kj/AsyncInputStream#registerAncillaryMessageHandler(36215211c2f6ef52).(
75 Functioncxx . . $ kj/Function#<void(ArrayPtrcxx . . $ kj/ArrayPtr#<AncillaryMessagecxx . . $ kj/AncillaryMessage#>)> fn) {
76 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("registerAncillaryMsgHandler is not implemented by this AsyncInputStream");
77 }
78
79 Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#>> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::tryTeecxx . . $ kj/AsyncInputStream#tryTee(76e5e1d7e74b7900).(uint64_tcxx . . $ uint64_t#) {
80 return nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
81 }
82
83 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
84
85 class AsyncPumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump# {
86 public:
87 AsyncPumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#AsyncPump(114171d833df4d64).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# limit, uint64_tcxx . . $ uint64_t# doneSoFar)
88 : inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#input.(input), outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#output.(output), limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#limit.(limit), doneSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#doneSoFar.(doneSoFar) {}
89
90 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#pump(6ca12f9220743fde).() {
91 // TODO(perf): This could be more efficient by reading half a buffer at a time and then
92 // starting the next read concurrent with writing the data from the previous read.
93
94 uint64_tcxx . . $ uint64_t# n = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#limit. - doneSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#doneSoFar., sizeof(buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#buffer.));
95 if (n == 0) return doneSoFarcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
96
97 return inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#input..tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#buffer., 1, n)
98 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this](size_t amount) -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
99 if (amount == 0) return doneSoFarcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).; // EOF
100 doneSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#doneSoFar. += amount;
101 return outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#output..writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#buffer., amount)
102 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
103 return pumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#pump(6ca12f9220743fde).();
104 });
105 });
106 }
107
108 private:
109 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#input.;
110 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#output.;
111 uint64_tcxx . . $ uint64_t# limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#limit.;
112 uint64_tcxx . . $ uint64_t# doneSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#doneSoFar.;
113 bytecxx . . $ kj/byte# buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#buffer.[4096];
114 };
115
116 } // namespace
117
118 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> unoptimizedPumpTocxx . . $ kj/unoptimizedPumpTo(a7f3142d388e3a0f).(
119 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount,
120 uint64_tcxx . . $ uint64_t# completedSoFar) {
121 auto pump = heapcxx . . $ kj/heap(bae2fec6325dc41a).<AsyncPumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#>(input, output, amount, completedSoFar);
122 auto promise = pump->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPump#pump(6ca12f9220743fde).();
123 return promise.attachcxx . . $ kj/Promise#attach(27d17a82377fab45).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pump));
124 }
125
126 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(
127 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) {
128 // See if output wants to dispatch on us.
129 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(result, output.tryPumpFrom(*this, amount)) {
130 return kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(*cxx . . $ kj/_/NullableValue#`operator*`(db8caaf2f996d67e).result);
131 }
132
133 // OK, fall back to naive approach.
134 return unoptimizedPumpTocxx . . $ kj/unoptimizedPumpTo(a7f3142d388e3a0f).(*this, output, amount);
135 }
136
137 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
138
139 class AllReadercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader# {
140 public:
141 AllReadercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#AllReader(9ef4b88652ba3c8f).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input): inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#input.(input) {}
142
143 Promisecxx . . $ kj/Promise#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> readAllBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#readAllBytes(13b4ce217ffb3254).(uint64_tcxx . . $ uint64_t# limit) {
144 return loopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#loop(29c7d4393f3c9e0e).(limit).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this, limit](uint64_tcxx . . $ uint64_t# headroom) {
145 auto out = heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<bytecxx . . $ kj/byte#>(limit - headroom);
146 copyIntocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#copyInto(263fd99fb500e72e).(out);
147 return outcxx . . $ kj/Array#Array(d736060a6fd4d37e).;
148 });
149 }
150
151 Promisecxx . . $ kj/Promise#<Stringcxx . . $ kj/String#> readAllTextcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#readAllText(a8f22fd94bbf40f5).(uint64_tcxx . . $ uint64_t# limit) {
152 return loopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#loop(29c7d4393f3c9e0e).(limit).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this, limit](uint64_tcxx . . $ uint64_t# headroom) {
153 auto out = heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<char>(limit - headroom + 1);
154 copyIntocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#copyInto(263fd99fb500e72e).(out.slicecxx . . $ kj/Array#slice(671e3291ea40e62f).(0, out.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).() - 1).asBytescxx . . $ kj/ArrayPtr#asBytes(8731b16708dd8915).());
155 out.backcxx . . $ kj/Array#back(19b2b6f17af048b).() = '\0';
156 return Stringcxx . . $ kj/String#String(74a5dfe5bc25aac).(kjcxx . . $ kj/Array#Array(d736060a6fd4d37e).::mvcxx . . $ kj/mv(9768e8ef939d477).(out));
157 });
158 }
159
160 private:
161 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#input.;
162 Vectorcxx . . $ kj/Vector#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> partscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#parts.;
163
164 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> loopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#loop(29c7d4393f3c9e0e).(uint64_tcxx . . $ uint64_t# limit) {
165 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(limit > 0, "Reached limit before EOF.");
166
167 auto part = heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<bytecxx . . $ kj/byte#>(kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(4096, limit));
168 auto partPtr = part.asPtrcxx . . $ kj/Array#asPtr(3a275942fa90435e).();
169 partscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#parts..addcxx . . $ kj/Vector#add(7f9966f43a57f391).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(part));
170 return inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#input..tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(partPtr.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), partPtr.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).(), partPtr.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).())
171 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,KJ_CPCAPcxx . . $ `src/kj/common.h:550:9`!(partPtr),limit](size_t amount) mutable -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
172 limit -= amount;
173 if (amount < partPtr.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
174 return limitcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
175 } else {
176 return loopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#loop(29c7d4393f3c9e0e).(limit);
177 }
178 });
179 }
180
181 void copyIntocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#copyInto(263fd99fb500e72e).(ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#> out) {
182 size_t pos = 0;
183 for (auto& part: partscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#parts.) {
184 size_t n = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(part.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).(), out.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() - pos);
185 memcpy(out.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).() + pos, part.begincxx . . $ kj/Array#begin(155dc7f103cdb9db).(), n);
186 pos += n;
187 }
188 }
189 };
190
191 } // namespace
192
193 Promisecxx . . $ kj/Promise#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::readAllBytescxx . . $ kj/AsyncInputStream#readAllBytes(13b4ce217ffb3254).(uint64_tcxx . . $ uint64_t# limit) {
194 auto reader = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<AllReadercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#>(*this);
195 auto promise = reader->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).readAllBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#readAllBytes(13b4ce217ffb3254).(limit);
196 return promise.attachcxx . . $ kj/Promise#attach(27d17a82377fab45).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(reader));
197 }
198
199 Promisecxx . . $ kj/Promise#<Stringcxx . . $ kj/String#> AsyncInputStreamcxx . . $ kj/AsyncInputStream#::readAllTextcxx . . $ kj/AsyncInputStream#readAllText(a8f22fd94bbf40f5).(uint64_tcxx . . $ uint64_t# limit) {
200 auto reader = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<AllReadercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#>(*this);
201 auto promise = reader->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).readAllTextcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AllReader#readAllText(a8f22fd94bbf40f5).(limit);
202 return promise.attachcxx . . $ kj/Promise#attach(27d17a82377fab45).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(reader));
203 }
204
205 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#::tryPumpFromcxx . . $ kj/AsyncOutputStream#tryPumpFrom(6d2b023c494552c3).(
206 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) {
207 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
208 }
209
210 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
211
212 class AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#, public Refcountedcxx . . $ kj/Refcounted# {
213 public:
214 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#`~AsyncPipe`(49f6e7a06ebc5aa8).AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#() noexcept(false) {
215 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(state == nullptr || ownState.get() != nullptr,
216 "destroying AsyncPipe with operation still in-progress; probably going to segfault") {
217 // Don't std::terminate().
218 break;
219 }
220 }
221
222 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
223 if (minBytes == 0) {
224 return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<size_t, 0>();
225 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
226 return s->tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes);
227 } else {
228 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#, BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#>(
229 *this, arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer), maxBytes), minBytes)
230 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# r) { return r.byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount.; });
231 }
232 }
233
234 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithFds(68a0207625b41c85).(void* buffer, size_t minBytes, size_t maxBytes,
235 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
236 if (minBytes == 0) {
237 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { 0, 0 };
238 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
239 return s->tryReadWithFdscxx . . $ kj/AsyncCapabilityStream#tryReadWithFds(68a0207625b41c85).(buffer, minBytes, maxBytes, fdBuffer, maxFds);
240 } else {
241 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#, BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#>(
242 *this, arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer), maxBytes), minBytes,
243 kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(fdBuffer, maxFds));
244 }
245 }
246
247 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithStreams(ff85abfb9995b3c3).(
248 void* buffer, size_t minBytes, size_t maxBytes,
249 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
250 if (minBytes == 0) {
251 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { 0, 0 };
252 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
253 return s->tryReadWithStreamscxx . . $ kj/AsyncCapabilityStream#tryReadWithStreams(ff85abfb9995b3c3).(buffer, minBytes, maxBytes, streamBuffer, maxStreams);
254 } else {
255 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#, BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#>(
256 *this, arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer), maxBytes), minBytes,
257 kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(streamBuffer, maxStreams));
258 }
259 }
260
261 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
262 if (amount == 0) {
263 return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<uint64_tcxx . . $ uint64_t#, 0>();
264 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
265 return s->pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(output, amount);
266 } else {
267 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<uint64_tcxx . . $ uint64_t#, BlockedPumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#>(*this, output, amount);
268 }
269 }
270
271 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).() override {
272 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
273 s->abortReadcxx . . $ kj/AsyncIoStream#abortRead(49f6e7a06ebc5aa8).();
274 } else {
275 ownStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ownState. =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<AbortedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#>();
276 statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).ownStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ownState.;
277
278 readAbortedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAborted. = true;
279 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(f, readAbortFulfiller) {
280 f->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->fulfillcxx . . $ kj/PromiseFulfiller#fulfill(a92516a8791c411b).();
281 readAbortFulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAbortFulfiller. =cxx . . $ kj/Maybe#`operator=`(1122f447bec8131d). nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
282 }
283 }
284 }
285
286 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
287 if (size == 0) {
288 return READY_NOWcxx . . $ kj/READY_NOW.;
289 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
290 return s->writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffer, size);
291 } else {
292 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<void, BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#>(
293 *this, arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<const bytecxx . . $ kj/byte#*>(buffer), size), nullptr);
294 }
295 }
296
297 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
298 while (pieces.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
299 pieces =cxx . . $ kj/ArrayPtr#`operator=`(1db1f54bc7b38063). pieces.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, pieces.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
300 }
301
302 if (pieces.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
303 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
304 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
305 return s->writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces);
306 } else {
307 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<void, BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#>(
308 *this, pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0], pieces.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, pieces.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()));
309 }
310 }
311
312 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
313 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
314 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
315 while (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0 && moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0) {
316 data =cxx . . $ kj/ArrayPtr#`operator=`(c3a6a213a904915e). moreData.frontcxx . . $ kj/ArrayPtr#front(19b2b6f17af048b).();
317 moreData =cxx . . $ kj/ArrayPtr#`operator=`(1db1f54bc7b38063). moreData.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
318 }
319
320 if (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
321 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(fds.size() == 0, "can't attach FDs to empty message");
322 return READY_NOWcxx . . $ kj/READY_NOW.;
323 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
324 return s->writeWithFdscxx . . $ kj/AsyncCapabilityStream#writeWithFds(d5524f9bb452a0e9).(data, moreData, fds);
325 } else {
326 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<void, BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#>(*this, data, moreData, fds);
327 }
328 }
329
330 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
331 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
332 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
333 while (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0 && moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0) {
334 data =cxx . . $ kj/ArrayPtr#`operator=`(c3a6a213a904915e). moreData.frontcxx . . $ kj/ArrayPtr#front(19b2b6f17af048b).();
335 moreData =cxx . . $ kj/ArrayPtr#`operator=`(1db1f54bc7b38063). moreData.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
336 }
337
338 if (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
339 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(streams.size() == 0, "can't attach capabilities to empty message");
340 return READY_NOWcxx . . $ kj/READY_NOW.;
341 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
342 return s->writeWithStreamscxx . . $ kj/AsyncCapabilityStream#writeWithStreams(73343d092f4f66e6).(data, moreData, kjcxx . . $ kj/Array#Array(d736060a6fd4d37e).::mvcxx . . $ kj/mv(9768e8ef939d477).(streams));
343 } else {
344 return newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<void, BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#>(*this, data, moreData, kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(streams));
345 }
346 }
347
348 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryPumpFrom(6d2b023c494552c3).(
349 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
350 if (amount == 0) {
351 return constPromisecxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70).<uint64_tcxx . . $ uint64_t#, 0>();
352 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
353 return s->tryPumpFromcxx . . $ kj/AsyncOutputStream#tryPumpFrom(6d2b023c494552c3).(input, amount);
354 } else {
355 return newAdaptedPromisecxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70).<uint64_tcxx . . $ uint64_t#, BlockedPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#>(*this, input, amount);
356 }
357 }
358
359 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#whenWriteDisconnected(542ddddf9229d39a).() override {
360 if (readAbortedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAborted.) {
361 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
362 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(p, readAbortPromise) {
363 return p->addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).();
364 } else {
365 auto paf = newPromiseAndFulfillercxx . . $ kj/newPromiseAndFulfiller(90de6d8a57426cdb).<void>();
366 readAbortFulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAbortFulfiller. =cxx . . $ kj/Maybe#`operator=`(1122f447bec8131d). kjcxx . . $ kj/Maybe#Maybe(d80f67c6086917eb).::mvcxx . . $ kj/mv(9768e8ef939d477).(paf.fulfillercxx . . $ kj/PromiseFulfillerPair#fulfiller.);
367 auto fork = paf.promisecxx . . $ kj/PromiseFulfillerPair#promise..forkcxx . . $ kj/Promise#fork(2ed7963d7a1857b8).();
368 auto result = fork.addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).();
369 readAbortPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAbortPromise. =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(fork);
370 return result;
371 }
372 }
373
374 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).() override {
375 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
376 s->shutdownWritecxx . . $ kj/AsyncIoStream#shutdownWrite(49f6e7a06ebc5aa8).();
377 } else {
378 ownStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ownState. =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<ShutdownedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#>();
379 statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).ownStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ownState.;
380 }
381 }
382
383 private:
384 Maybecxx . . $ kj/Maybe#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#&> statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state.;
385 // Object-oriented state! If any method call is blocked waiting on activity from the other end,
386 // then `state` is non-null and method calls should be forwarded to it. If no calls are
387 // outstanding, `state` is null.
388
389 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#> ownStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ownState.;
390
391 bool readAbortedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAborted. = false;
392 Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<PromiseFulfillercxx . . $ kj/PromiseFulfiller#<void>>> readAbortFulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAbortFulfiller. = nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
393 Maybecxx . . $ kj/Maybe#<ForkedPromisecxx . . $ kj/ForkedPromise#<void>> readAbortPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#readAbortPromise. = nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
394
395 void endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(AsyncIoStreamcxx . . $ kj/AsyncIoStream#& obj) {
396 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, state) {
397 if (s == &obj) {
398 statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(2e6fced1831a5860). nullptr;
399 }
400 }
401 }
402
403 template <typename F>
404 static auto teeExceptionVoidcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionVoid(68d5cc880c741df5).(F& fulfiller) {
405 // Returns a functor that can be passed as the second parameter to .then() to propagate the
406 // exception to a given fulfiller. The functor's return type is void.
407 return [&fulfiller](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) {
408 fulfiller.reject(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(e));
409 kjcxx . . $ kj/::throwRecoverableExceptioncxx . . $ kj/throwRecoverableException(6529c6cadc6e9b51).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(e));
410 };
411 }
412 template <typename F>
413 static auto teeExceptionSizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionSize(68d5cc880c741df5).(F& fulfiller) {
414 // Returns a functor that can be passed as the second parameter to .then() to propagate the
415 // exception to a given fulfiller. The functor's return type is size_t.
416 return [&fulfiller](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) -> size_t {
417 fulfiller.reject(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(e));
418 kjcxx . . $ kj/::throwRecoverableExceptioncxx . . $ kj/throwRecoverableException(6529c6cadc6e9b51).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(e));
419 return 0;
420 };
421 }
422 template <typename T, typename F>
423 static auto teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).(F& fulfiller) {
424 // Returns a functor that can be passed as the second parameter to .then() to propagate the
425 // exception to a given fulfiller. The functor's return type is Promise<T>.
426 return [&fulfiller](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) -> kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<T> {
427 fulfiller.reject(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(e));
428 return kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(e);
429 };
430 }
431
432 class BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
433 // AsyncPipe state when a write() is currently waiting for a corresponding read().
434
435 public:
436 BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#BlockedWrite(1634dbddf26b7127).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<void>& fulfiller, AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipe,
437 ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> writeBuffer,
438 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> morePieces,
439 kjcxx . . $ kj/::OneOfcxx . . $ kj/OneOf#<ArrayPtrcxx . . $ kj/ArrayPtr#<const int>, Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>> capBuffer =cxx . . $ kj/OneOf#OneOf(49f6e7a06ebc5aa8). {})
440 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller.(fulfiller), pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe.(pipe), writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer.(writeBuffer), morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.(morePieces),
441 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#capBuffer.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(capBuffer)) {
442 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(pipe.state == nullptr);
443 pipe.statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *this;
444 }
445
446 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#`~BlockedWrite`(49f6e7a06ebc5aa8).BlockedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#() noexcept(false) {
447 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
448 }
449
450 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
451 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(tryReadImpl(buffer, minBytes, maxBytes)) {
452 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
453 return donecxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9)..resultcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done#result.;
454 }
455 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
456 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryRead(1d893319628a2258).(retry.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#buffer., retry.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#minBytes., retry.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#maxBytes.)
457 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([n = retry.alreadyReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#alreadyRead.](size_t amount) { return amount + n; });
458 }
459 }
460 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
461 }
462
463 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#tryReadWithFds(68a0207625b41c85).(void* buffer, size_t minBytes, size_t maxBytes,
464 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
465 size_t capCount = 0;
466 { // TODO(cleanup): Remove redundant braces when we update to C++17.
467 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(capBuffer) {
468 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(fds, ArrayPtr<const int>) {
469 capCount = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(fds.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).(), maxFds);
470 // Unfortunately, we have to dup() each FD, because the writer doesn't release ownership
471 // by default.
472 // TODO(perf): Should we add an ownership-releasing version of writeWithFds()?
473 for (auto i: kjcxx . . $ kj/::zeroTocxx . . $ kj/zeroTo(79d3e41e5132f71a).(capCount)) {
474 int duped;
475 KJ_SYSCALLcxx . . $ `src/kj/debug.h:236:9`!(duped = dup(fds[i]));
476 fdBuffer[i] =cxx . . $ kj/AutoCloseFd#`operator=`(1ff0321f41d5b2b3). kjcxx . . $ kj/::AutoCloseFdcxx . . $ kj/AutoCloseFd#(fds[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i]);
477 }
478 fdBuffer += capCount;
479 maxFds -= capCount;
480 }
481 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(streams, Array<Own<AsyncCapabilityStream>>) {
482 if (streams.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).() > 0 && maxFds > 0) {
483 // TODO(someday): We could let people pass a LowLevelAsyncIoProvider to
484 // newTwoWayPipe() if we wanted to auto-wrap FDs, but does anyone care?
485 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!(
486 "async pipe message was written with streams attached, but corresponding read "
487 "asked for FDs, and we don't know how to convert here");
488 }
489 }
490 }
491 }
492
493 // Drop any unclaimed caps. This mirrors the behavior of unix sockets, where if we didn't
494 // provide enough buffer space for all the written FDs, the remaining ones are lost.
495 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#capBuffer. =cxx . . $ kj/OneOf#`operator=`(ece7a766a6f5767a). {cxx . . $ kj/OneOf#OneOf(49f6e7a06ebc5aa8).};
496
497 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(tryReadImpl(buffer, minBytes, maxBytes)) {
498 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
499 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { done.resultcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done#result., capCount };
500 }
501 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
502 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithFds(68a0207625b41c85).(
503 retry.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#buffer., retry.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#minBytes., retry.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#maxBytes., fdBuffer, maxFds)
504 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([byteCount = retry.alreadyReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#alreadyRead., capCount](ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# result) {
505 result.byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. += byteCount;
506 result.capCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#capCount. += capCount;
507 return result;
508 });
509 }
510 }
511 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
512 }
513
514 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#tryReadWithStreams(ff85abfb9995b3c3).(
515 void* buffer, size_t minBytes, size_t maxBytes,
516 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
517 size_t capCount = 0;
518 { // TODO(cleanup): Remove redundant braces when we update to C++17.
519 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(capBuffer) {
520 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(fds, ArrayPtr<const int>) {
521 if (fds.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && maxStreams > 0) {
522 // TODO(someday): Use AsyncIoStream's `Maybe<int> getFd()` method?
523 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!(
524 "async pipe message was written with FDs attached, but corresponding read "
525 "asked for streams, and we don't know how to convert here");
526 }
527 }
528 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(streams, Array<Own<AsyncCapabilityStream>>) {
529 capCount = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(streams.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).(), maxStreams);
530 for (auto i: kjcxx . . $ kj/::zeroTocxx . . $ kj/zeroTo(79d3e41e5132f71a).(capCount)) {
531 streamBuffer[i] =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(streams[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).i]);
532 }
533 streamBuffer += capCount;
534 maxStreams -= capCount;
535 }
536 }
537 }
538
539 // Drop any unclaimed caps. This mirrors the behavior of unix sockets, where if we didn't
540 // provide enough buffer space for all the written FDs, the remaining ones are lost.
541 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#capBuffer. =cxx . . $ kj/OneOf#`operator=`(ece7a766a6f5767a). {cxx . . $ kj/OneOf#OneOf(49f6e7a06ebc5aa8).};
542
543 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(tryReadImpl(buffer, minBytes, maxBytes)) {
544 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
545 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { done.resultcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done#result., capCount };
546 }
547 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
548 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithStreams(ff85abfb9995b3c3).(
549 retry.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#buffer., retry.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#minBytes., retry.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#maxBytes., streamBuffer, maxStreams)
550 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([byteCount = retry.alreadyReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#alreadyRead., capCount](ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# result) {
551 result.byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. += byteCount;
552 result.capCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#capCount. += capCount;
553 return result;
554 });
555 }
556 }
557 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
558 }
559
560 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
561 // Note: Pumps drop all capabilities.
562 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
563
564 if (amount < writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
565 // Consume a portion of the write buffer.
566 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(output.writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), amount)
567 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,amount]() {
568 writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(596308cff75d5c06). writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(amount, writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
569 // We pumped the full amount, so we're done pumping.
570 return amount;
571 }, teeExceptionSizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionSize(68d5cc880c741df5).(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller.)));
572 }
573
574 // First piece doesn't cover the whole pump. Figure out how many more pieces to add.
575 uint64_tcxx . . $ uint64_t# actual = writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
576 size_t i = 0;
577 while (i < morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() &&
578 amount >= actual + morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
579 actual += morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i++].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
580 }
581
582 // Write the first piece.
583 auto promise = output.writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
584
585 // Write full pieces as a single gather-write.
586 if (i > 0) {
587 auto more = morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(0, i);
588 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([&output,more]() { return output.writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(more); });
589 }
590
591 if (i == morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
592 // This will complete the write.
593 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&output,amount,actual]() -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
594 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
595 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(a92516a8791c411b).();
596 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
597
598 if (actual == amount) {
599 // Oh, we had exactly enough.
600 return actualcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
601 } else {
602 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#pumpTo(779d39587ccc1d6c).(output, amount - actual)
603 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([actual](uint64_tcxx . . $ uint64_t# actual2) { return actual + actual2; });
604 }
605 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<uint64_tcxx . . $ uint64_t#>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller.)));
606 } else {
607 // Pump ends mid-piece. Write the last, partial piece.
608 auto n = amount - actual;
609 auto splitPiece = morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i];
610 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(n <= splitPiece.size());
611 auto newWriteBuffer = splitPiece.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(n, splitPiece.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
612 auto newMorePieces = morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(i + 1, morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
613 auto prefix = splitPiece.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(0, n);
614 if (prefix.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0) {
615 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([&output,prefix]() {
616 return output.writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(prefix.begincxx . . $ kj/ArrayPtr#begin(1016ee5406d91ab9).(), prefix.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
617 });
618 }
619
620 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,newWriteBuffer,newMorePieces,amount]() {
621 writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(c3a6a213a904915e). newWriteBuffer;
622 morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces. =cxx . . $ kj/ArrayPtr#`operator=`(5fa7b3bad2047023). newMorePieces;
623 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
624 return amount;
625 }, teeExceptionSizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionSize(68d5cc880c741df5).(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller.)));
626 }
627 }
628
629 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#abortRead(49f6e7a06ebc5aa8).() override {
630 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("abortRead() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
631 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "read end of pipe was aborted"));
632 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
633 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
634 }
635
636 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
637 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous write() completes");
638 }
639 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
640 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous write() completes");
641 }
642 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
643 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
644 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
645 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous write() completes");
646 }
647 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
648 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
649 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
650 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous write() completes");
651 }
652 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
653 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't tryPumpFrom() again until previous write() completes");
654 }
655 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#shutdownWrite(49f6e7a06ebc5aa8).() override {
656 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't shutdownWrite() until previous write() completes");
657 }
658
659 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#whenWriteDisconnected(542ddddf9229d39a).() override {
660 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
661 }
662
663 private:
664 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<void>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller.;
665 AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe.;
666 ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer.;
667 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.;
668 kjcxx . . $ kj/::OneOfcxx . . $ kj/OneOf#<ArrayPtrcxx . . $ kj/ArrayPtr#<const int>, Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>> capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#capBuffer.;
669 Cancelercxx . . $ kj/Canceler# cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#canceler.;
670
671 struct Donecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done# { size_t resultcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done#result.; };
672 struct Retrycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry# { void* buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#buffer.; size_t minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#minBytes.; size_t maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#maxBytes.; size_t alreadyReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#alreadyRead.; };
673
674 OneOfcxx . . $ kj/OneOf#<Donecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Done#, Retrycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#Retry#> tryReadImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#tryReadImpl(a0ab5e607ddd169b).(void* readBufferPtr, size_t minBytes, size_t maxBytes) {
675 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
676
677 auto readBuffer = arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(readBufferPtr), maxBytes);
678
679 size_t totalRead = 0;
680 while (readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() >= writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
681 // The whole current write buffer can be copied into the read buffer.
682
683 {
684 auto n = writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
685 memcpy(readBuffer.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), n);
686 totalRead += n;
687 readBuffer =cxx . . $ kj/ArrayPtr#`operator=`(d8484f2dc887c4f0). readBuffer.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(n, readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
688 }
689
690 if (morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
691 // All done writing.
692 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(a92516a8791c411b).();
693 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
694
695 if (totalRead >= minBytes) {
696 // Also all done reading.
697 return Donecxx . . $ kj/OneOf#OneOf(4f6c0277e8680150). { totalRead };
698 } else {
699 return Retrycxx . . $ kj/OneOf#OneOf(4f6c0277e8680150). { readBuffer.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), minBytes - totalRead, readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).(), totalRead };
700 }
701 }
702
703 writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(c3a6a213a904915e). morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces.[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0];
704 morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces. =cxx . . $ kj/ArrayPtr#`operator=`(1db1f54bc7b38063). morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, morePiecescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#morePieces..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
705 }
706
707 // At this point, the read buffer is smaller than the current write buffer, so we can fill
708 // it completely.
709 {
710 auto n = readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
711 memcpy(readBuffer.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), n);
712 writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(596308cff75d5c06). writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(n, writeBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedWrite#writeBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
713 totalRead += n;
714 }
715
716 return Donecxx . . $ kj/OneOf#OneOf(4f6c0277e8680150). { totalRead };
717 }
718 };
719
720 class BlockedPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
721 // AsyncPipe state when a tryPumpFrom() is currently waiting for a corresponding read().
722
723 public:
724 BlockedPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#BlockedPumpFrom(6319151a1501a194).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<uint64_tcxx . . $ uint64_t#>& fulfiller, AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipe,
725 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount)
726 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller.(fulfiller), pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe.(pipe), inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#input.(input), amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount.(amount) {
727 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(pipe.state == nullptr);
728 pipe.statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *this;
729 }
730
731 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#`~BlockedPumpFrom`(49f6e7a06ebc5aa8).BlockedPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#() noexcept(false) {
732 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
733 }
734
735 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryRead(1d893319628a2258).(void* readBuffer, size_t minBytes, size_t maxBytes) override {
736 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
737
738 auto pumpLeft = amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount. - pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar.;
739 auto min = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(pumpLeft, minBytes);
740 auto max = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(pumpLeft, maxBytes);
741 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#input..tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(readBuffer, min, max)
742 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,readBuffer,minBytes,maxBytes,min](size_t actual) -> kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<size_t> {
743 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
744 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar. += actual;
745 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar <= amount);
746
747 if (pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar. == amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount. || actual < min) {
748 // Either we pumped all we wanted or we hit EOF.
749 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar.));
750 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
751 }
752
753 if (actual >= minBytes) {
754 return actualcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
755 } else {
756 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryRead(1d893319628a2258).(reinterpret_cast<bytecxx . . $ kj/byte#*>(readBuffer) + actual,
757 minBytes - actual, maxBytes - actual)
758 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([actual](size_t actual2) { return actual + actual2; });
759 }
760 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<size_t>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller.)));
761 }
762
763 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryReadWithFds(68a0207625b41c85).(void* readBuffer, size_t minBytes, size_t maxBytes,
764 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
765 // Pumps drop all capabilities, so fall back to regular read. (We don't even know if the
766 // destination is an AsyncCapabilityStream...)
767 return tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryRead(1d893319628a2258).(readBuffer, minBytes, maxBytes)
768 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](size_t n) { return ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# { n, 0 }; });
769 }
770
771 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryReadWithStreams(ff85abfb9995b3c3).(
772 void* readBuffer, size_t minBytes, size_t maxBytes,
773 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
774 // Pumps drop all capabilities, so fall back to regular read. (We don't even know if the
775 // destination is an AsyncCapabilityStream...)
776 return tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryRead(1d893319628a2258).(readBuffer, minBytes, maxBytes)
777 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](size_t n) { return ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# { n, 0 }; });
778 }
779
780 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount2) override {
781 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
782
783 auto n = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount2, amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount. - pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar.);
784 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#input..pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(output, n)
785 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&output,amount2,n](uint64_tcxx . . $ uint64_t# actual) -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
786 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
787 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar. += actual;
788 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar <= amount);
789 if (pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar. == amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount. || actual < n) {
790 // Either we pumped all we wanted or we hit EOF.
791 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar.));
792 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
793 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#pumpTo(779d39587ccc1d6c).(output, amount2 - actual)
794 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([actual](uint64_tcxx . . $ uint64_t# actual2) { return actual + actual2; });
795 }
796
797 // Completed entire pumpTo amount.
798 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(actual == amount2);
799 return amount2cxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
800 }, teeExceptionSizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionSize(68d5cc880c741df5).(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller.)));
801 }
802
803 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#abortRead(49f6e7a06ebc5aa8).() override {
804 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("abortRead() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
805
806 // The input might have reached EOF, but we haven't detected it yet because we haven't tried
807 // to read that far. If we had not optimized tryPumpFrom() and instead used the default
808 // pumpTo() implementation, then the input would not have called write() again once it
809 // reached EOF, and therefore the abortRead() on the other end would *not* propagate an
810 // exception! We need the same behavior here. To that end, we need to detect if we're at EOF
811 // by reading one last byte.
812 checkEofTaskcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#checkEofTask. =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). kjcxx . . $ kj/::evalNowcxx . . $ kj/evalNow(2a9d78fa55ded97b).([&]() {
813 static char junk;
814 return inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#input..tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(&junk, 1, 1).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this](uint64_tcxx . . $ uint64_t# n) {
815 if (n == 0) {
816 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar.));
817 } else {
818 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "read end of pipe was aborted"));
819 }
820 }).eagerlyEvaluatecxx . . $ kj/Promise#eagerlyEvaluate(2be579741f6bb3d).([this](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) {
821 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(e));
822 });
823 });
824
825 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
826 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe..abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
827 }
828
829 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
830 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous tryPumpFrom() completes");
831 }
832 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
833 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous tryPumpFrom() completes");
834 }
835 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
836 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
837 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
838 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous tryPumpFrom() completes");
839 }
840 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
841 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
842 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
843 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't write() again until previous tryPumpFrom() completes");
844 }
845 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
846 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't tryPumpFrom() again until previous tryPumpFrom() completes");
847 }
848 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#shutdownWrite(49f6e7a06ebc5aa8).() override {
849 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't shutdownWrite() until previous tryPumpFrom() completes");
850 }
851
852 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#whenWriteDisconnected(542ddddf9229d39a).() override {
853 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
854 }
855
856 private:
857 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<uint64_tcxx . . $ uint64_t#>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#fulfiller.;
858 AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pipe.;
859 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& inputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#input.;
860 uint64_tcxx . . $ uint64_t# amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#amount.;
861 uint64_tcxx . . $ uint64_t# pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#pumpedSoFar. = 0;
862 Cancelercxx . . $ kj/Canceler# cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#canceler.;
863 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> checkEofTaskcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpFrom#checkEofTask. = nullptrcxx . . $ kj/Promise#Promise(49b4c06ce5d54a60).;
864 };
865
866 class BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
867 // AsyncPipe state when a tryRead() is currently waiting for a corresponding write().
868
869 public:
870 BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#BlockedRead(c3da927897e6bfa5).(
871 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#>& fulfiller, AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipe,
872 ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#> readBuffer, size_t minBytes,
873 kjcxx . . $ kj/::OneOfcxx . . $ kj/OneOf#<ArrayPtrcxx . . $ kj/ArrayPtr#<AutoCloseFdcxx . . $ kj/AutoCloseFd#>, ArrayPtrcxx . . $ kj/ArrayPtr#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>> capBuffer =cxx . . $ kj/OneOf#OneOf(49f6e7a06ebc5aa8). {})
874 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller.(fulfiller), pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe.(pipe), readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer.(readBuffer), minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#minBytes.(minBytes),
875 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#capBuffer.(capBuffer) {
876 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(pipe.state == nullptr);
877 pipe.statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *this;
878 }
879
880 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#`~BlockedRead`(49f6e7a06ebc5aa8).BlockedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#() noexcept(false) {
881 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
882 }
883
884 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#tryRead(1d893319628a2258).(void* readBuffer, size_t minBytes, size_t maxBytes) override {
885 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous read() completes");
886 }
887 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#tryReadWithFds(68a0207625b41c85).(void* readBuffer, size_t minBytes, size_t maxBytes,
888 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
889 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous read() completes");
890 }
891 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#tryReadWithStreams(ff85abfb9995b3c3).(
892 void* readBuffer, size_t minBytes, size_t maxBytes,
893 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
894 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous read() completes");
895 }
896 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
897 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous read() completes");
898 }
899
900 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#abortRead(49f6e7a06ebc5aa8).() override {
901 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("abortRead() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
902 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "read end of pipe was aborted"));
903 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
904 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
905 }
906
907 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#write(7ee344f2bd176b7a).(const void* writeBuffer, size_t size) override {
908 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
909
910 auto data = arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<const bytecxx . . $ kj/byte#*>(writeBuffer), size);
911 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(writeImpl(data, nullptr)) {
912 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
913 return READY_NOWcxx . . $ kj/READY_NOW.;
914 }
915 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
916 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(retry.moreData == nullptr);
917 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
918 }
919 }
920 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
921 }
922
923 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
924 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
925
926 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(writeImpl(pieces[0], pieces.slice(1, pieces.size()))) {
927 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
928 return READY_NOWcxx . . $ kj/READY_NOW.;
929 }
930 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
931 if (retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
932 // We exactly finished the current piece, so just issue a write for the remaining
933 // pieces.
934 if (retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
935 // Nothing left.
936 return READY_NOWcxx . . $ kj/READY_NOW.;
937 } else {
938 // Write remaining pieces.
939 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData.);
940 }
941 } else {
942 // Unfortunately we have to execute a separate write() for the remaining part of this
943 // piece, because we can't modify the pieces array.
944 auto promise = pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
945 if (retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
946 // No more pieces so that's it.
947 return kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(promise);
948 } else {
949 // Also need to write the remaining pieces.
950 auto& pipeRef = pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe.;
951 return promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([pieces=retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData.,&pipeRef]() {
952 return pipeRef.writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(pieces);
953 });
954 }
955 }
956 }
957 }
958 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
959 }
960
961 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
962 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
963 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
964 #if __GNUC__cxx . . $ `<built-in>:8:9`! && !__clang__cxx . . $ `<built-in>:3:9`! && __GNUC__cxx . . $ `<built-in>:8:9`! >= 7
965 // GCC 7 decides the open-brace below is "misleadingly indented" as if it were guarded by the `for`
966 // that appears in the implementation of KJ_REQUIRE(). Shut up shut up shut up.
967 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
968 #endif
969 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
970
971 { // TODO(cleanup): Remove redundant braces when we update to C++17.
972 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(capBuffer) {
973 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(fdBuffer, ArrayPtr<AutoCloseFd>) {
974 size_t count = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(fdBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).(), fds.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
975 // Unfortunately, we have to dup() each FD, because the writer doesn't release ownership
976 // by default.
977 // TODO(perf): Should we add an ownership-releasing version of writeWithFds()?
978 for (auto i: kjcxx . . $ kj/::zeroTocxx . . $ kj/zeroTo(79d3e41e5132f71a).(count)) {
979 int duped;
980 KJ_SYSCALLcxx . . $ `src/kj/debug.h:236:9`!(duped = dup(fds[i]));
981 fdBuffer[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i] =cxx . . $ kj/AutoCloseFd#`operator=`(1ff0321f41d5b2b3). kjcxx . . $ kj/::AutoCloseFdcxx . . $ kj/AutoCloseFd#(duped);
982 }
983 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#capBuffer. =cxx . . $ kj/OneOf#`operator=`(ece7a766a6f5767a). fdBuffercxx . . $ kj/OneOf#OneOf(4f6c0277e8680150)..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(count, fdBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
984 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..capCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#capCount. += count;
985 }
986 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(streamBuffer, ArrayPtr<Own<AsyncCapabilityStream>>) {
987 if (streamBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && fds.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0) {
988 // TODO(someday): Use AsyncIoStream's `Maybe<int> getFd()` method?
989 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!(
990 "async pipe message was written with FDs attached, but corresponding read "
991 "asked for streams, and we don't know how to convert here");
992 }
993 }
994 }
995 }
996
997 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(writeImpl(data, moreData)) {
998 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
999 return READY_NOWcxx . . $ kj/READY_NOW.;
1000 }
1001 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
1002 // Any leftover fds in `fds` are dropped on the floor, per contract.
1003 // TODO(cleanup): We use another writeWithFds() call here only because it accepts `data`
1004 // and `moreData` directly. After the stream API refactor, we should be able to avoid
1005 // this.
1006 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithFds(d5524f9bb452a0e9).(retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data., retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData., nullptrcxx . . $ kj/ArrayPtr#ArrayPtr(49b4c06ce5d54a60).);
1007 }
1008 }
1009 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
1010 }
1011
1012 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1013 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1014 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
1015 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
1016
1017 { // TODO(cleanup): Remove redundant braces when we update to C++17.
1018 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(capBuffer) {
1019 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(fdBuffer, ArrayPtr<AutoCloseFd>) {
1020 if (fdBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && streams.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).() > 0) {
1021 // TODO(someday): We could let people pass a LowLevelAsyncIoProvider to newTwoWayPipe()
1022 // if we wanted to auto-wrap FDs, but does anyone care?
1023 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!(
1024 "async pipe message was written with streams attached, but corresponding read "
1025 "asked for FDs, and we don't know how to convert here");
1026 }
1027 }
1028 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(streamBuffer, ArrayPtr<Own<AsyncCapabilityStream>>) {
1029 size_t count = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(streamBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).(), streams.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).());
1030 for (auto i: kjcxx . . $ kj/::zeroTocxx . . $ kj/zeroTo(79d3e41e5132f71a).(count)) {
1031 streamBuffer[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i] =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(streams[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).i]);
1032 }
1033 capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#capBuffer. =cxx . . $ kj/OneOf#`operator=`(ece7a766a6f5767a). streamBuffercxx . . $ kj/OneOf#OneOf(4f6c0277e8680150)..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(count, streamBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1034 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..capCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#capCount. += count;
1035 }
1036 }
1037 }
1038
1039 KJ_SWITCH_ONEOFcxx . . $ `src/kj/one-of.h:608:9`!(writeImpl(data, moreData)) {
1040 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(done, Done) {
1041 return READY_NOWcxx . . $ kj/READY_NOW.;
1042 }
1043 KJ_CASE_ONEOFcxx . . $ `src/kj/one-of.h:617:9`!(retry, Retry) {
1044 // Any leftover fds in `fds` are dropped on the floor, per contract.
1045 // TODO(cleanup): We use another writeWithStreams() call here only because it accepts
1046 // `data` and `moreData` directly. After the stream API refactor, we should be able to
1047 // avoid this.
1048 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithStreams(73343d092f4f66e6).(retry.datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data., retry.moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData., nullptrcxx . . $ kj/Array#Array(49b4c06ce5d54a60).);
1049 }
1050 }
1051 KJ_UNREACHABLEcxx . . $ `src/kj/common.h:360:9`!;
1052 }
1053
1054 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
1055 // Note: Pumps drop all capabilities.
1056 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
1057
1058 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(minBytes > readSoFar.byteCount);
1059 auto minToRead = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount, minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#minBytes. - readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount.);
1060 auto maxToRead = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount, readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1061
1062 return cancelercxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70)..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(input.tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), minToRead, maxToRead)
1063 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&input,amount](size_t actual) -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
1064 readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(d8484f2dc887c4f0). readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(actual, readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1065 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. += actual;
1066
1067 if (readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. >= minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#minBytes.) {
1068 // We've read enough to close out this read (readSoFar >= minBytes).
1069 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1070 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar.));
1071 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1072
1073 if (actual < amount) {
1074 // We didn't read as much data as the pump requested, but we did fulfill the read, so
1075 // we don't know whether we reached EOF on the input. We need to continue the pump,
1076 // replacing the BlockedRead state.
1077 return input.pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe., amount - actual)
1078 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([actual](uint64_tcxx . . $ uint64_t# actual2) -> uint64_tcxx . . $ uint64_t# { return actual + actual2; });
1079 } else {
1080 // We pumped as much data as was requested, so we can return that now.
1081 return actualcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1082 }
1083 } else {
1084 // The pump completed without fulfilling the read. This either means that the pump
1085 // reached EOF or the `amount` requested was not enough to satisfy the read in the first
1086 // place. Pumps do not propagate EOF, so either way we want to leave the BlockedRead in
1087 // place waiting for more data.
1088 return actualcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1089 }
1090 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<uint64_tcxx . . $ uint64_t#>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller.)));
1091 }
1092
1093 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#shutdownWrite(49f6e7a06ebc5aa8).() override {
1094 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("shutdownWrite() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
1095 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar.));
1096 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1097 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).();
1098 }
1099
1100 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#whenWriteDisconnected(542ddddf9229d39a).() override {
1101 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
1102 }
1103
1104 private:
1105 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller.;
1106 AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe.;
1107 ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#> readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer.;
1108 size_t minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#minBytes.;
1109 kjcxx . . $ kj/::OneOfcxx . . $ kj/OneOf#<ArrayPtrcxx . . $ kj/ArrayPtr#<AutoCloseFdcxx . . $ kj/AutoCloseFd#>, ArrayPtrcxx . . $ kj/ArrayPtr#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>> capBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#capBuffer.;
1110 ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar. = {0, 0};
1111 Cancelercxx . . $ kj/Canceler# cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#canceler.;
1112
1113 struct Donecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Done# {};
1114 struct Retrycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry# { ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> datacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#data.; ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreDatacxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#moreData.; };
1115
1116 OneOfcxx . . $ kj/OneOf#<Donecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Done#, Retrycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#Retry#> writeImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#writeImpl(19f903f072bd35b5).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1117 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData) {
1118 for (;;) {
1119 if (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() < readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).()) {
1120 // First write segment consumes a portion of the read buffer but not all of it.
1121 auto n = data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
1122 memcpy(readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), data.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), n);
1123 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. += n;
1124 readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer. =cxx . . $ kj/ArrayPtr#`operator=`(d8484f2dc887c4f0). readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(n, readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1125 if (moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
1126 // Consumed all written pieces.
1127 if (readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. >= minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#minBytes.) {
1128 // We've read enough to close out this read.
1129 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar.));
1130 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1131 }
1132 return Donecxx . . $ kj/OneOf#OneOf(4f6c0277e8680150).();
1133 }
1134 data =cxx . . $ kj/ArrayPtr#`operator=`(c3a6a213a904915e). moreData[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0];
1135 moreData =cxx . . $ kj/ArrayPtr#`operator=`(1db1f54bc7b38063). moreData.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(1, moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1136 // loop
1137 } else {
1138 // First write segment consumes entire read buffer.
1139 auto n = readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
1140 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar..byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. += n;
1141 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readSoFar.));
1142 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1143 memcpy(readBuffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedRead#readBuffer..begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), data.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), n);
1144
1145 data =cxx . . $ kj/ArrayPtr#`operator=`(596308cff75d5c06). data.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(n, data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1146 if (data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0 && moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
1147 return Donecxx . . $ kj/OneOf#OneOf(4f6c0277e8680150).();
1148 } else {
1149 // Note: Even if `data` is empty, we don't replace it with moreData[0], because the
1150 // retry might need to use write(ArrayPtr<ArrayPtr<byte>>) which doesn't allow
1151 // passing a separate first segment.
1152 return Retrycxx . . $ kj/OneOf#OneOf(4f6c0277e8680150). { data, moreData };
1153 }
1154 }
1155 }
1156 }
1157 };
1158
1159 class BlockedPumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
1160 // AsyncPipe state when a pumpTo() is currently waiting for a corresponding write().
1161
1162 public:
1163 BlockedPumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#BlockedPumpTo(c6d7125264d8357c).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<uint64_tcxx . . $ uint64_t#>& fulfiller, AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipe,
1164 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount)
1165 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.(fulfiller), pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe.(pipe), outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output.(output), amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.(amount) {
1166 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(pipe.state == nullptr);
1167 pipe.statecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#state. =cxx . . $ kj/Maybe#`operator=`(58a27d4210775e5a). *this;
1168 }
1169
1170 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#`~BlockedPumpTo`(49f6e7a06ebc5aa8).BlockedPumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#() noexcept(false) {
1171 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1172 }
1173
1174 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#tryRead(1d893319628a2258).(void* readBuffer, size_t minBytes, size_t maxBytes) override {
1175 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous pumpTo() completes");
1176 }
1177 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#tryReadWithFds(68a0207625b41c85).(void* readBuffer, size_t minBytes, size_t maxBytes,
1178 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
1179 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous pumpTo() completes");
1180 }
1181 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#tryReadWithStreams(ff85abfb9995b3c3).(
1182 void* readBuffer, size_t minBytes, size_t maxBytes,
1183 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
1184 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous pumpTo() completes");
1185 }
1186 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1187 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("can't read() again until previous pumpTo() completes");
1188 }
1189
1190 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#abortRead(49f6e7a06ebc5aa8).() override {
1191 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("abortRead() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
1192 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "read end of pipe was aborted"));
1193 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1194 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
1195 }
1196
1197 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(7ee344f2bd176b7a).(const void* writeBuffer, size_t size) override {
1198 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
1199
1200 auto actual = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount. - pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar., size);
1201 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output..writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(writeBuffer, actual)
1202 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,size,actual,writeBuffer]() -> kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> {
1203 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1204 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. += actual;
1205
1206 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar <= amount);
1207 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(actual <= size);
1208
1209 if (pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. == amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.) {
1210 // Done with pump.
1211 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar.));
1212 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1213 }
1214
1215 if (actual == size) {
1216 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
1217 } else {
1218 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar == amount);
1219 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(reinterpret_cast<const bytecxx . . $ kj/byte#*>(writeBuffer) + actual, size - actual);
1220 }
1221 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<void>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.)));
1222 }
1223
1224 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
1225 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
1226
1227 size_t size = 0;
1228 size_t needed = amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount. - pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar.;
1229 for (auto i: kjcxx . . $ kj/::indicescxx . . $ kj/indices(5511956b41a96918).(pieces)) {
1230 if (pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > needed) {
1231 // The pump ends in the middle of this write.
1232
1233 auto promise = outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output..writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(0, i));
1234
1235 if (needed > 0) {
1236 // The pump includes part of this piece, but not all. Unfortunately we need to split
1237 // writes.
1238 auto partial = pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].slicecxx . . $ kj/ArrayPtr#slice(f0c0f5e40ca648d8).(0, needed);
1239 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,partial]() {
1240 return outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output..writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(partial.begincxx . . $ kj/ArrayPtr#begin(1016ee5406d91ab9).(), partial.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1241 });
1242 auto partial2 = pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].slicecxx . . $ kj/ArrayPtr#slice(f0c0f5e40ca648d8).(needed, pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1243 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,partial2]() {
1244 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1245 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.));
1246 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1247 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(partial2.begincxx . . $ kj/ArrayPtr#begin(1016ee5406d91ab9).(), partial2.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1248 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<void>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.)));
1249 ++i;
1250 } else {
1251 // The pump ends exactly at the end of a piece, how nice.
1252 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
1253 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1254 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.));
1255 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1256 }, teeExceptionVoidcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionVoid(68d5cc880c741df5).(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.)));
1257 }
1258
1259 auto remainder = pieces.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(i, pieces.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1260 if (remainder.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0) {
1261 auto& pipeRef = pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe.;
1262 promise =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([&pipeRef,remainder]() {
1263 return pipeRef.writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(remainder);
1264 });
1265 }
1266
1267 return promise;
1268 } else {
1269 size += pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
1270 needed -= pieces[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).i].sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
1271 }
1272 }
1273
1274 // Turns out we can forward this whole write.
1275 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(size <= amount - pumpedSoFar);
1276 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output..writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,size]() {
1277 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. += size;
1278 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar <= amount);
1279 if (pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. == amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.) {
1280 // Done pumping.
1281 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1282 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.));
1283 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1284 }
1285 }, teeExceptionVoidcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionVoid(68d5cc880c741df5).(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.)));
1286 }
1287
1288 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1289 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1290 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
1291 // Pumps drop all capabilities, so fall back to regular write().
1292
1293 // TODO(cleaunp): After stream API refactor, regular write() methods will take
1294 // (data, moreData) and we can clean this up.
1295 if (moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
1296 return writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(7ee344f2bd176b7a).(data.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1297 } else {
1298 auto pieces = kjcxx . . $ kj/::heapArrayBuildercxx . . $ kj/heapArrayBuilder(c94a6ea09e06c018).<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>>(moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() + 1);
1299 pieces.addcxx . . $ kj/ArrayBuilder#add(7f9966f43a57f391).(data);
1300 pieces.addAllcxx . . $ kj/ArrayBuilder#addAll(4f6c0277e8680150).(moreData);
1301 return writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(251ec43b44baa62).(pieces.finishcxx . . $ kj/ArrayBuilder#finish(dcb0cb35f23a4119).());
1302 }
1303 }
1304
1305 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1306 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1307 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
1308 // Pumps drop all capabilities, so fall back to regular write().
1309
1310 // TODO(cleaunp): After stream API refactor, regular write() methods will take
1311 // (data, moreData) and we can clean this up.
1312 if (moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() == 0) {
1313 return writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(7ee344f2bd176b7a).(data.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), data.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
1314 } else {
1315 auto pieces = kjcxx . . $ kj/::heapArrayBuildercxx . . $ kj/heapArrayBuilder(c94a6ea09e06c018).<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>>(moreData.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() + 1);
1316 pieces.addcxx . . $ kj/ArrayBuilder#add(7f9966f43a57f391).(data);
1317 pieces.addAllcxx . . $ kj/ArrayBuilder#addAll(4f6c0277e8680150).(moreData);
1318 return writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#write(251ec43b44baa62).(pieces.finishcxx . . $ kj/ArrayBuilder#finish(dcb0cb35f23a4119).());
1319 }
1320 }
1321
1322 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount2) override {
1323 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(canceler.isEmpty(), "already pumping");
1324
1325 auto n = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount2, amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount. - pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar.);
1326 return outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output..tryPumpFromcxx . . $ kj/AsyncOutputStream#tryPumpFrom(6d2b023c494552c3).(input, n)
1327 .mapcxx . . $ kj/Maybe#map(b21c3b56008e630e).([&](Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> subPump) {
1328 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(subPump
1329 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&input,amount2,n](uint64_tcxx . . $ uint64_t# actual) -> Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> {
1330 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..releasecxx . . $ kj/Canceler#release(49f6e7a06ebc5aa8).();
1331 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. += actual;
1332 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar <= amount);
1333 if (pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. == amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.) {
1334 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.));
1335 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1336 }
1337
1338 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(actual <= amount2);
1339 if (actual == amount2) {
1340 // Completed entire tryPumpFrom amount.
1341 return amount2cxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1342 } else if (actual < n) {
1343 // Received less than requested, presumably because EOF.
1344 return actualcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1345 } else {
1346 // We received all the bytes that were requested but it didn't complete the pump.
1347 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(pumpedSoFar == amount);
1348 return input.pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe., amount2 - actual);
1349 }
1350 }, teeExceptionPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#teeExceptionPromise(be4552b70fe3666f).<uint64_tcxx . . $ uint64_t#>(fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.)));
1351 });
1352 }
1353
1354 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#shutdownWrite(49f6e7a06ebc5aa8).() override {
1355 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("shutdownWrite() was called"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
1356 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::cpcxx . . $ kj/cp(e3e566e686e04411).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar.));
1357 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..endStatecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#endState(54c5e86485612032).(*this);
1358 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe..shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).();
1359 }
1360
1361 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#whenWriteDisconnected(542ddddf9229d39a).() override {
1362 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
1363 }
1364
1365 private:
1366 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<uint64_tcxx . . $ uint64_t#>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#fulfiller.;
1367 AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#& pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pipe.;
1368 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#output.;
1369 uint64_tcxx . . $ uint64_t# amountcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#amount.;
1370 size_t pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#pumpedSoFar. = 0;
1371 Cancelercxx . . $ kj/Canceler# cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#BlockedPumpTo#canceler.;
1372 };
1373
1374 class AbortedReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
1375 // AsyncPipe state when abortRead() has been called.
1376
1377 public:
1378 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#tryRead(1d893319628a2258).(void* readBufferPtr, size_t minBytes, size_t maxBytes) override {
1379 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1380 }
1381 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#tryReadWithFds(68a0207625b41c85).(void* readBuffer, size_t minBytes, size_t maxBytes,
1382 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
1383 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1384 }
1385 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#tryReadWithStreams(ff85abfb9995b3c3).(
1386 void* readBuffer, size_t minBytes, size_t maxBytes,
1387 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
1388 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1389 }
1390 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1391 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1392 }
1393 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#abortRead(49f6e7a06ebc5aa8).() override {
1394 // ignore repeated abort
1395 }
1396
1397 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
1398 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1399 }
1400 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
1401 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1402 }
1403 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1404 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1405 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
1406 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1407 }
1408 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1409 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1410 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
1411 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called");
1412 }
1413 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
1414 // There might not actually be any data in `input`, in which case a pump wouldn't actually
1415 // write anything and wouldn't fail.
1416
1417 if (input.tryGetLengthcxx . . $ kj/AsyncInputStream#tryGetLength(b0ae5156aeb9187c).().orDefaultcxx . . $ kj/Maybe#orDefault(dbf35d25cbfec61d).(1) == 0) {
1418 // Yeah a pump would pump nothing.
1419 return constPromisecxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70).<uint64_tcxx . . $ uint64_t#, 0>();
1420 } else {
1421 // While we *could* just return nullptr here, it would probably then fall back to a normal
1422 // buffered pump, which would allocate a big old buffer just to find there's nothing to
1423 // read. Let's try reading 1 byte to avoid that allocation.
1424 static char c;
1425 return inputcxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70)..tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(&c, 1, 1).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](size_t n) {
1426 if (n == 0) {
1427 // Yay, we're at EOF as hoped.
1428 return uint64_tcxx . . $ uint64_t#(0);
1429 } else {
1430 // There was data in the input. The pump would have thrown.
1431 kjcxx . . $ kj/::throwRecoverableExceptioncxx . . $ kj/throwRecoverableException(6529c6cadc6e9b51).(
1432 KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED, "abortRead() has been called"));
1433 return uint64_tcxx . . $ uint64_t#(0);
1434 }
1435 });
1436 }
1437 }
1438 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#shutdownWrite(49f6e7a06ebc5aa8).() override {
1439 // ignore -- currently shutdownWrite() actually means that the PipeWriteEnd was dropped,
1440 // which is not an error even if reads have been aborted.
1441 }
1442 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#AbortedRead#whenWriteDisconnected(542ddddf9229d39a).() override {
1443 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
1444 }
1445 };
1446
1447 class ShutdownedWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
1448 // AsyncPipe state when shutdownWrite() has been called.
1449
1450 public:
1451 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#tryRead(1d893319628a2258).(void* readBufferPtr, size_t minBytes, size_t maxBytes) override {
1452 return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<size_t, 0>();
1453 }
1454 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#tryReadWithFds(68a0207625b41c85).(void* readBuffer, size_t minBytes, size_t maxBytes,
1455 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
1456 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { 0, 0 };
1457 }
1458 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#tryReadWithStreams(ff85abfb9995b3c3).(
1459 void* readBuffer, size_t minBytes, size_t maxBytes,
1460 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
1461 return ReadResultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9). { 0, 0 };
1462 }
1463 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1464 return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<uint64_tcxx . . $ uint64_t#, 0>();
1465 }
1466 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#abortRead(49f6e7a06ebc5aa8).() override {
1467 // ignore
1468 }
1469
1470 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
1471 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("shutdownWrite() has been called");
1472 }
1473 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
1474 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("shutdownWrite() has been called");
1475 }
1476 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1477 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1478 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
1479 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("shutdownWrite() has been called");
1480 }
1481 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1482 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1483 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
1484 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("shutdownWrite() has been called");
1485 }
1486 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#tryPumpFrom(6d2b023c494552c3).(AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
1487 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("shutdownWrite() has been called");
1488 }
1489 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#shutdownWrite(49f6e7a06ebc5aa8).() override {
1490 // ignore -- currently shutdownWrite() actually means that the PipeWriteEnd was dropped,
1491 // so it will only be called once anyhow.
1492 }
1493 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#ShutdownedWrite#whenWriteDisconnected(542ddddf9229d39a).() override {
1494 KJ_FAIL_ASSERTcxx . . $ `src/kj/debug.h:360:9`!("can't get here -- implemented by AsyncPipe");
1495 }
1496 };
1497 };
1498
1499 class PipeReadEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd# final: public AsyncInputStreamcxx . . $ kj/AsyncInputStream# {
1500 public:
1501 PipeReadEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#PipeReadEnd(ec20dbab681e39c6).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> pipe): pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pipe.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe)) {}
1502 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#`~PipeReadEnd`(49f6e7a06ebc5aa8).PipeReadEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#() noexcept(false) {
1503 unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#unwind..catchExceptionsIfUnwindingcxx . . $ kj/UnwindDetector#catchExceptionsIfUnwinding(8c463d1e13f06b00).([&]() {
1504 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
1505 });
1506 }
1507
1508 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
1509 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes);
1510 }
1511
1512 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1513 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#pumpTo(779d39587ccc1d6c).(output, amount);
1514 }
1515
1516 private:
1517 Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#pipe.;
1518 UnwindDetectorcxx . . $ kj/UnwindDetector# unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#unwind.;
1519 };
1520
1521 class PipeWriteEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd# final: public AsyncOutputStreamcxx . . $ kj/AsyncOutputStream# {
1522 public:
1523 PipeWriteEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#PipeWriteEnd(ec20dbab681e39c6).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> pipe): pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe)) {}
1524 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#`~PipeWriteEnd`(49f6e7a06ebc5aa8).PipeWriteEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#() noexcept(false) {
1525 unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#unwind..catchExceptionsIfUnwindingcxx . . $ kj/UnwindDetector#catchExceptionsIfUnwinding(8c463d1e13f06b00).([&]() {
1526 pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).();
1527 });
1528 }
1529
1530 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
1531 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(buffer, size);
1532 }
1533
1534 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
1535 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(pieces);
1536 }
1537
1538 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#tryPumpFrom(6d2b023c494552c3).(
1539 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
1540 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryPumpFrom(6d2b023c494552c3).(input, amount);
1541 }
1542
1543 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#whenWriteDisconnected(542ddddf9229d39a).() override {
1544 return pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#whenWriteDisconnected(542ddddf9229d39a).();
1545 }
1546
1547 private:
1548 Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> pipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#pipe.;
1549 UnwindDetectorcxx . . $ kj/UnwindDetector# unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#unwind.;
1550 };
1551
1552 class TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd# final: public AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream# {
1553 public:
1554 TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#TwoWayPipeEnd(bc14fa8ad7b218cc).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> in, kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> out)
1555 : incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(in)), outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(out)) {}
1556 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#`~TwoWayPipeEnd`(49f6e7a06ebc5aa8).TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#() noexcept(false) {
1557 unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#unwind..catchExceptionsIfUnwindingcxx . . $ kj/UnwindDetector#catchExceptionsIfUnwinding(8c463d1e13f06b00).([&]() {
1558 outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).();
1559 incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
1560 });
1561 }
1562
1563 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
1564 return incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes);
1565 }
1566 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#tryReadWithFds(68a0207625b41c85).(void* buffer, size_t minBytes, size_t maxBytes,
1567 AutoCloseFdcxx . . $ kj/AutoCloseFd#* fdBuffer, size_t maxFds) override {
1568 return incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithFds(68a0207625b41c85).(buffer, minBytes, maxBytes, fdBuffer, maxFds);
1569 }
1570 Promisecxx . . $ kj/Promise#<ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult#> tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#tryReadWithStreams(ff85abfb9995b3c3).(
1571 void* buffer, size_t minBytes, size_t maxBytes,
1572 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>* streamBuffer, size_t maxStreams) override {
1573 return incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryReadWithStreams(ff85abfb9995b3c3).(buffer, minBytes, maxBytes, streamBuffer, maxStreams);
1574 }
1575 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1576 return incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#pumpTo(779d39587ccc1d6c).(output, amount);
1577 }
1578 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#abortRead(49f6e7a06ebc5aa8).() override {
1579 incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#abortRead(49f6e7a06ebc5aa8).();
1580 }
1581
1582 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
1583 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(7ee344f2bd176b7a).(buffer, size);
1584 }
1585 Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
1586 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#write(251ec43b44baa62).(pieces);
1587 }
1588 Promisecxx . . $ kj/Promise#<void> writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#writeWithFds(d5524f9bb452a0e9).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1589 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1590 ArrayPtrcxx . . $ kj/ArrayPtr#<const int> fds) override {
1591 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writeWithFdscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithFds(d5524f9bb452a0e9).(data, moreData, fds);
1592 }
1593 Promisecxx . . $ kj/Promise#<void> writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#writeWithStreams(73343d092f4f66e6).(ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data,
1594 ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
1595 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> streams) override {
1596 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writeWithStreamscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#writeWithStreams(73343d092f4f66e6).(data, moreData, kjcxx . . $ kj/Array#Array(d736060a6fd4d37e).::mvcxx . . $ kj/mv(9768e8ef939d477).(streams));
1597 }
1598 Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#tryPumpFrom(6d2b023c494552c3).(
1599 AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount) override {
1600 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#tryPumpFrom(6d2b023c494552c3).(input, amount);
1601 }
1602 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#whenWriteDisconnected(542ddddf9229d39a).() override {
1603 return outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#whenWriteDisconnected(542ddddf9229d39a).();
1604 }
1605 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#shutdownWrite(49f6e7a06ebc5aa8).() override {
1606 outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#shutdownWrite(49f6e7a06ebc5aa8).();
1607 }
1608
1609 private:
1610 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> incxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#in.;
1611 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#> outcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#out.;
1612 UnwindDetectorcxx . . $ kj/UnwindDetector# unwindcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#unwind.;
1613 };
1614
1615 class LimitedInputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream# final: public AsyncInputStreamcxx . . $ kj/AsyncInputStream# {
1616 public:
1617 LimitedInputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#LimitedInputStream(ce6ba8645e1166c).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> inner, uint64_tcxx . . $ uint64_t# limit)
1618 : innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(inner)), limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit.(limit) {
1619 if (limit == 0) {
1620 this->innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner. =cxx . . $ kj/Own#`operator=`(ddec55f583c0ae05). nullptr;
1621 }
1622 }
1623
1624 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> tryGetLengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#tryGetLength(b0ae5156aeb9187c).() override {
1625 return limitcxx . . $ kj/Maybe#Maybe(8e935d9c2e576e3a).;
1626 }
1627
1628 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
1629 if (limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit. == 0) return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<size_t, 0>();
1630 return innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffer, kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(minBytes, limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit.), kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(maxBytes, limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit.))
1631 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,minBytes](size_t actual) {
1632 decreaseLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#decreaseLimit(6714b5f2551eea49).(actual, minBytes);
1633 return actual;
1634 });
1635 }
1636
1637 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1638 if (limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit. == 0) return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<uint64_tcxx . . $ uint64_t#, 0>();
1639 auto requested = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount, limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit.);
1640 return innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(output, requested)
1641 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,requested](uint64_tcxx . . $ uint64_t# actual) {
1642 decreaseLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#decreaseLimit(6714b5f2551eea49).(actual, requested);
1643 return actual;
1644 });
1645 }
1646
1647 private:
1648 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner.;
1649 uint64_tcxx . . $ uint64_t# limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit.;
1650
1651 void decreaseLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#decreaseLimit(6714b5f2551eea49).(uint64_tcxx . . $ uint64_t# amount, uint64_tcxx . . $ uint64_t# requested) {
1652 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(limit >= amount);
1653 limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit. -= amount;
1654 if (limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#limit. == 0) {
1655 innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#inner. =cxx . . $ kj/Own#`operator=`(ddec55f583c0ae05). nullptr;
1656 } else if (amount < requested) {
1657 kjcxx . . $ kj/::throwRecoverableExceptioncxx . . $ kj/throwRecoverableException(6529c6cadc6e9b51).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(DISCONNECTED,
1658 "fixed-length pipe ended prematurely"));
1659 }
1660 }
1661 };
1662
1663 } // namespace
1664
1665 OneWayPipecxx . . $ kj/OneWayPipe# newOneWayPipecxx . . $ kj/newOneWayPipe(fa224d01a280fb53).(kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> expectedLength) {
1666 auto impl = kjcxx . . $ kj/::refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#>();
1667 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> readEnd = kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<PipeReadEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeReadEnd#>(kjcxx . . $ kj/::addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).impl));
1668 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(l, expectedLength) {
1669 readEnd =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<LimitedInputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LimitedInputStream#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(readEnd), *l);
1670 }
1671 Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#> writeEnd = kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<PipeWriteEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PipeWriteEnd#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(impl));
1672 return { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(readEnd), kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(writeEnd) };
1673 }
1674
1675 TwoWayPipecxx . . $ kj/TwoWayPipe# newTwoWayPipecxx . . $ kj/newTwoWayPipe(f1f56754b7651e3e).() {
1676 auto pipe1 = kjcxx . . $ kj/::refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#>();
1677 auto pipe2 = kjcxx . . $ kj/::refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#>();
1678 auto end1 = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#>(kjcxx . . $ kj/::addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).pipe1), kjcxx . . $ kj/::addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).pipe2));
1679 auto end2 = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe2), kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe1));
1680 return { { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(end1), kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(end2) } };
1681 }
1682
1683 CapabilityPipecxx . . $ kj/CapabilityPipe# newCapabilityPipecxx . . $ kj/newCapabilityPipe(69844c81ff968e52).() {
1684 auto pipe1 = kjcxx . . $ kj/::refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#>();
1685 auto pipe2 = kjcxx . . $ kj/::refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncPipecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncPipe#>();
1686 auto end1 = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#>(kjcxx . . $ kj/::addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).pipe1), kjcxx . . $ kj/::addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).pipe2));
1687 auto end2 = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<TwoWayPipeEndcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/TwoWayPipeEnd#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe2), kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe1));
1688 return { { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(end1), kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(end2) } };
1689 }
1690
1691 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
1692
1693 class AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee# final: public Refcountedcxx . . $ kj/Refcounted# {
1694 class Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer# {
1695 public:
1696 Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#Buffer(49f6e7a06ebc5aa8).() = default;
1697
1698 uint64_tcxx . . $ uint64_t# consumecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#consume(50c90a1416dd0f03).(ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#>& readBuffer, size_t& minBytes);
1699 // Consume as many bytes as possible, copying them into `readBuffer`. Return the number of bytes
1700 // consumed.
1701 //
1702 // `readBuffer` and `minBytes` are both assigned appropriate new values, such that after any
1703 // call to `consume()`, `readBuffer` will point to the remaining slice of unwritten space, and
1704 // `minBytes` will have been decremented (clamped to zero) by the amount of bytes read. That is,
1705 // the read can be considered fulfilled if `minBytes` is zero after a call to `consume()`.
1706
1707 Arraycxx . . $ kj/Array#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> asArraycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#asArray(2db0eeaf38c966e1).(uint64_tcxx . . $ uint64_t# minBytes, uint64_tcxx . . $ uint64_t#& amount);
1708 // Consume the first `minBytes` of the buffer (or the entire buffer) and return it in an Array
1709 // of ArrayPtr<const byte>s, suitable for passing to AsyncOutputStream.write(). The outer Array
1710 // owns the underlying data.
1711
1712 void producecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#produce(5fedcad8c6f5b64a).(Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#> bytes);
1713 // Enqueue a byte array to the end of the buffer list.
1714
1715 bool emptycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#empty(50ce9a9e25b4a850).() const;
1716 uint64_tcxx . . $ uint64_t# sizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#size(fe4d2d262d4164a8).() const;
1717
1718 Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer# clonecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#clone(fe57a8b685647e07).() const {
1719 size_t size = 0;
1720 for (const auto& buf: bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList.) {
1721 size += buf.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
1722 }
1723 auto builder = heapArrayBuildercxx . . $ kj/heapArrayBuilder(c94a6ea09e06c018).<bytecxx . . $ kj/byte#>(size);
1724 for (const auto& buf: bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList.) {
1725 builder.addAllcxx . . $ kj/ArrayBuilder#addAll(4f6c0277e8680150).(buf);
1726 }
1727 stdcxx . . $ std/::dequecxx . . $ std/deque#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> dequecxx . . $ std/deque#deque(49f6e7a06ebc5aa8).;
1728 deque.emplace_backcxx . . $ std/deque#emplace_back(df8c12b98d24bd1e).(builder.finishcxx . . $ kj/ArrayBuilder#finish(dcb0cb35f23a4119).());
1729 return Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#Buffer(f0ecab6a66fe98c6).{mvcxx . . $ kj/mv(9768e8ef939d477).(deque)};
1730 }
1731
1732 private:
1733 Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#Buffer(f0ecab6a66fe98c6).(stdcxx . . $ std/::dequecxx . . $ std/deque#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>>&& buffer) : bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList.(mvcxx . . $ kj/mv(9768e8ef939d477).(buffer)) {}
1734
1735 stdcxx . . $ std/::dequecxx . . $ std/deque#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList.;
1736 };
1737
1738 class Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#;
1739
1740 public:
1741 class Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch# final: public AsyncInputStreamcxx . . $ kj/AsyncInputStream# {
1742 public:
1743 Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#Branch(91ab94028e66396c).(Owncxx . . $ kj/Own#<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#> teeArg): teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.(mvcxx . . $ kj/mv(9768e8ef939d477).(teeArg)) {
1744 teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches..addcxx . . $ kj/List#add(8e935d9c2e576e3a).(*this);
1745 }
1746
1747 Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#Branch(16d677b6e30a8d12).(Owncxx . . $ kj/Own#<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#> teeArg, Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#& cloneFrom)
1748 : teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.(mvcxx . . $ kj/mv(9768e8ef939d477).(teeArg)), buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer.(cloneFrom.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..clonecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#clone(fe57a8b685647e07).()) {
1749 teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches..addcxx . . $ kj/List#add(8e935d9c2e576e3a).(*this);
1750 }
1751
1752 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#`~Branch`(49f6e7a06ebc5aa8).Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#() noexcept(false) {
1753 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(link.isLinked()) {
1754 // Don't std::terminate().
1755 return;
1756 }
1757 teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches..removecxx . . $ kj/List#remove(8e935d9c2e576e3a).(*this);
1758
1759 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(sink == nullptr,
1760 "destroying tee branch with operation still in-progress; probably going to segfault") {
1761 // Don't std::terminate().
1762 break;
1763 }
1764 }
1765
1766 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
1767 return teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#tryRead(78edc6c511b744b5).(*this, buffer, minBytes, maxBytes);
1768 }
1769
1770 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#pumpTo(779d39587ccc1d6c).(AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
1771 return teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pumpTo(5792292249e2fe55).(*this, output, amount);
1772 }
1773
1774 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> tryGetLengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tryGetLength(b0ae5156aeb9187c).() override {
1775 return teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryGetLengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#tryGetLength(76ca7952b1e7b9bd).(*this);
1776 }
1777
1778 Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#>> tryTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tryTee(76e5e1d7e74b7900).(uint64_tcxx . . $ uint64_t# limit) override {
1779 if (teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).getBufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#getBufferSizeLimit(fe4d2d262d4164a8).() != limit) {
1780 // Cannot optimize this path as the limit has changed, so we need a new AsyncTee to manage
1781 // the limit.
1782 return nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
1783 }
1784
1785 return kjcxx . . $ kj/Maybe#Maybe(21ddcd3ac9f13cf).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#>(addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.), *this);
1786 }
1787
1788 private:
1789 Owncxx . . $ kj/Own#<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#> teecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#tee.;
1790 ListLinkcxx . . $ kj/ListLink#<Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#> linkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#link.;
1791
1792 Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer# buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer.;
1793 Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#&> sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#sink.;
1794
1795 friend class AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#;
1796 };
1797
1798 explicit AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#AsyncTee(ce6ba8645e1166c).(Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> inner, uint64_tcxx . . $ uint64_t# bufferSizeLimit)
1799 : innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#inner.(mvcxx . . $ kj/mv(9768e8ef939d477).(inner)), bufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#bufferSizeLimit.(bufferSizeLimit), lengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#length.(this->innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#inner.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryGetLengthcxx . . $ kj/AsyncInputStream#tryGetLength(b0ae5156aeb9187c).()) {}
1800 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#`~AsyncTee`(49f6e7a06ebc5aa8).AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#() noexcept(false) {
1801 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(branches.size() == 0, "destroying AsyncTee with branch still alive") {
1802 // Don't std::terminate().
1803 break;
1804 }
1805 }
1806
1807 Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#tryRead(78edc6c511b744b5).(Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#& branch, void* buffer, size_t minBytes, size_t maxBytes) {
1808 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(branch.sink == nullptr);
1809
1810 // If there is excess data in the buffer for us, slurp that up.
1811 auto readBuffer = arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer), maxBytes);
1812 auto readSoFar = branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..consumecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#consume(50c90a1416dd0f03).(readBuffer, minBytes);
1813
1814 if (minBytes == 0) {
1815 return readSoFarcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1816 }
1817
1818 if (branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..emptycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#empty(50ce9a9e25b4a850).()) {
1819 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(reason, stoppage) {
1820 // Prefer a short read to an exception. The exception prevents the pull loop from adding any
1821 // data to the buffer, so `readSoFar` will be zero the next time someone calls `tryRead()`,
1822 // and the caller will see the exception.
1823 if (reason->iscxx . . $ kj/OneOf#is(50ce9a9e25b4a850).<Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#>() || readSoFar > 0) {
1824 return readSoFarcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1825 }
1826 return cpcxx . . $ kj/Promise#Promise(c33f37f983fdaa7c).(reason->getcxx . . $ kj/OneOf#get(9417494582e45a0b).<Exceptioncxx . . $ kj/Exception#>());
1827 }
1828 }
1829
1830 auto promise = newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<size_t, ReadSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#>(
1831 branch.sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#sink., readBuffer, minBytes, readSoFar);
1832 ensurePullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ensurePulling(49f6e7a06ebc5aa8).();
1833 return mvcxx . . $ kj/mv(9768e8ef939d477).(promise);
1834 }
1835
1836 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> tryGetLengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#tryGetLength(76ca7952b1e7b9bd).(Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#& branch) {
1837 return lengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#length..mapcxx . . $ kj/Maybe#map(15cd17b8f10d1038).([&branch](uint64_tcxx . . $ uint64_t# amount) {
1838 return amount + branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..sizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#size(fe4d2d262d4164a8).();
1839 });
1840 }
1841
1842 uint64_tcxx . . $ uint64_t# getBufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#getBufferSizeLimit(fe4d2d262d4164a8).() const {
1843 return bufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#bufferSizeLimit.;
1844 }
1845
1846 Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pumpTo(5792292249e2fe55).(Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#& branch, AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) {
1847 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(branch.sink == nullptr);
1848
1849 if (amount == 0) {
1850 return amountcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
1851 }
1852
1853 if (branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..emptycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#empty(50ce9a9e25b4a850).()) {
1854 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(reason, stoppage) {
1855 if (reason->iscxx . . $ kj/OneOf#is(50ce9a9e25b4a850).<Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#>()) {
1856 return constPromisecxx . . $ kj/constPromise(5668e015fc35486c).<uint64_tcxx . . $ uint64_t#, 0>();
1857 }
1858 return cpcxx . . $ kj/Promise#Promise(c33f37f983fdaa7c).(reason->getcxx . . $ kj/OneOf#get(9417494582e45a0b).<Exceptioncxx . . $ kj/Exception#>());
1859 }
1860 }
1861
1862 auto promise = newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<uint64_tcxx . . $ uint64_t#, PumpSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#>(branch.sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#sink., output, amount);
1863 ensurePullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ensurePulling(49f6e7a06ebc5aa8).();
1864 return mvcxx . . $ kj/mv(9768e8ef939d477).(promise);
1865 }
1866
1867 private:
1868 struct Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof# {};
1869 using Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage# = OneOfcxx . . $ kj/OneOf#<Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#, Exceptioncxx . . $ kj/Exception#>;
1870
1871 class Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink# {
1872 public:
1873 struct Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# {
1874 // We use uint64_t here because:
1875 // - pumpTo() accepts it as the `amount` parameter.
1876 // - all practical values of tryRead()'s `maxBytes` parameter (a size_t) should also fit into
1877 // a uint64_t, unless we're on a machine with multiple exabytes of memory ...
1878
1879 uint64_tcxx . . $ uint64_t# minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#minBytes. = 0;
1880
1881 uint64_tcxx . . $ uint64_t# maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes. = kjcxx . . $ kj/::maxValuecxx . . $ kj/maxValue.;
1882 };
1883
1884 virtual Promisecxx . . $ kj/Promise#<void> fillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#fill(c63e5418c7ac6f55).(Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#& inBuffer, const Maybecxx . . $ kj/Maybe#<Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#>& stoppage) = 0;
1885 // Attempt to fill the sink with bytes andreturn a promise which must resolve before any inner
1886 // read may be attempted. If a sink requires backpressure to be respected, this is how it should
1887 // be communicated.
1888 //
1889 // If the sink is full, it must detach from the tee before the returned promise is resolved.
1890 //
1891 // The returned promise must not result in an exception.
1892
1893 virtual Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#need(994e2decc18b1e76).() = 0;
1894
1895 virtual void rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#reject(c33f37f983fdaa7c).(Exceptioncxx . . $ kj/Exception#&& exception) = 0;
1896 // Inform this sink of a catastrophic exception and detach it. Regular read exceptions should be
1897 // propagated through `fill()`'s stoppage parameter instead.
1898 };
1899
1900 template <typename T>
1901 class SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#: public Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink# {
1902 // Registers itself with the tee as a sink on construction, detaches from the tee on
1903 // fulfillment, rejection, or destruction.
1904 //
1905 // A bit of a Frankenstein, avert your eyes. For one thing, it's more of a mixin than a base...
1906
1907 public:
1908 explicit SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#`SinkBase<T>`(73abdcb511852b75).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<T>& fulfiller, Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#&>& sinkLink)
1909 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfiller.(fulfiller), sinkLinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#sinkLink.(sinkLink) {
1910 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(sinkLink == nullptr, "sink initiated with sink already in flight");
1911 sinkLink = *this;
1912 }
1913 KJ_DISALLOW_COPY_AND_MOVEcxx . . $ `src/kj/common.h:201:9`!(SinkBase);
1914 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#`~SinkBase<T>`(49f6e7a06ebc5aa8).SinkBase() noexcept(false) { detachcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#detach(49f6e7a06ebc5aa8).(); }
1915
1916 void rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#reject(c33f37f983fdaa7c).(Exceptioncxx . . $ kj/Exception#&& exception) override {
1917 // The tee is allowed to reject this sink if it needs to, e.g. to propagate a non-inner read
1918 // exception from the pull loop. Only the derived class is allowed to fulfill() directly,
1919 // though -- the tee must keep calling fill().
1920
1921 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(mvcxx . . $ kj/mv(9768e8ef939d477).(exception));
1922 detachcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#detach(49f6e7a06ebc5aa8).();
1923 }
1924
1925 protected:
1926 template <typename U>
1927 void fulfillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfill(b07662a27bd562f9).(U value) {
1928 fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(fwdcxx . . $ kj/fwd(68f4e95e387cd780).<U>(value));
1929 detachcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#detach(49f6e7a06ebc5aa8).();
1930 }
1931
1932 private:
1933 void detachcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#detach(49f6e7a06ebc5aa8).() {
1934 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(sink, sinkLink) {
1935 if (sink ==cxx . . $ kj/`operator==`(d65311d0a28cd285). this) {
1936 sinkLinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#sinkLink. =cxx . . $ kj/Maybe#`operator=`(2e6fced1831a5860). nullptr;
1937 }
1938 }
1939 }
1940
1941 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<T>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfiller.;
1942 Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#&>& sinkLinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#sinkLink.;
1943 };
1944
1945 class ReadSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink# final: public SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#<size_t> {
1946 public:
1947 explicit ReadSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#ReadSink(99de50b9cfb0dec4).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<size_t>& fulfiller, Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#&>& registration,
1948 ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#> buffer, size_t minBytes, size_t readSoFar)
1949 : SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#(fulfiller, registration), buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#buffer.(buffer),
1950 minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#minBytes.(minBytes), readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar.(readSoFar) {}
1951
1952 Promisecxx . . $ kj/Promise#<void> fillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#fill(c63e5418c7ac6f55).(Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#& inBuffer, const Maybecxx . . $ kj/Maybe#<Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#>& stoppage) override {
1953 auto amount = inBuffer.consumecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#consume(50c90a1416dd0f03).(buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#buffer., minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#minBytes.);
1954 readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar. += amount;
1955
1956 if (minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#minBytes. == 0) {
1957 // We satisfied the read request.
1958 fulfillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfill(b07662a27bd562f9).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar.);
1959 return READY_NOWcxx . . $ kj/READY_NOW.;
1960 }
1961
1962 if (amount == 0 && inBuffer.emptycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#empty(50ce9a9e25b4a850).()) {
1963 // We made no progress on the read request and the buffer is tapped out.
1964 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(reason, stoppage) {
1965 if (reason->iscxx . . $ kj/OneOf#is(50ce9a9e25b4a850).<Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#>() || readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar. > 0) {
1966 // Prefer short read to exception.
1967 fulfillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfill(b07662a27bd562f9).(readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar.);
1968 } else {
1969 rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#reject(c33f37f983fdaa7c).(cpcxx . . $ kj/cp(a09425ded2739bff).(reason->getcxx . . $ kj/OneOf#get(4111f073734757b).<Exceptioncxx . . $ kj/Exception#>()));
1970 }
1971 return READY_NOWcxx . . $ kj/READY_NOW.;
1972 }
1973 }
1974
1975 return READY_NOWcxx . . $ kj/READY_NOW.;
1976 }
1977
1978 Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#need(994e2decc18b1e76).() override { return Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# { minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#minBytes., buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#buffer..sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() }; }
1979
1980 private:
1981 ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#> buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#buffer.;
1982 size_t minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#minBytes.;
1983 // Arguments to the outer tryRead() call, sliced/decremented after every buffer consumption.
1984
1985 size_t readSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ReadSink#readSoFar.;
1986 // End result of the outer tryRead().
1987 };
1988
1989 class PumpSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink# final: public SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#<uint64_tcxx . . $ uint64_t#> {
1990 public:
1991 explicit PumpSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#PumpSink(ed116d551904fb99).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<uint64_tcxx . . $ uint64_t#>& fulfiller, Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#&>& registration,
1992 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# limit)
1993 : SinkBasecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#(fulfiller, registration), outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#output.(output), limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit.(limit) {}
1994
1995 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#`~PumpSink`(49f6e7a06ebc5aa8).PumpSinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#() noexcept(false) {
1996 cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#canceler..cancelcxx . . $ kj/Canceler#cancel(9daf31930a91c4f1).("This pump has been canceled."cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).);
1997 }
1998
1999 Promisecxx . . $ kj/Promise#<void> fillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#fill(c63e5418c7ac6f55).(Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#& inBuffer, const Maybecxx . . $ kj/Maybe#<Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#>& stoppage) override {
2000 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(limit > 0);
2001
2002 uint64_tcxx . . $ uint64_t# amount = 0;
2003
2004 // TODO(someday): This consumes data from the buffer, but we cannot know if the stream to
2005 // which we're pumping will accept it until after the write() promise completes. If the
2006 // write() promise rejects, we lose this data. We should consume the data from the buffer
2007 // only after successful writes.
2008 auto writeBuffer = inBuffer.asArraycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#asArray(2db0eeaf38c966e1).(limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit., amount);
2009 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(limit >= amount);
2010 if (amount > 0) {
2011 Promisecxx . . $ kj/Promise#<void> promise = kjcxx . . $ kj/::evalNowcxx . . $ kj/evalNow(2a9d78fa55ded97b).([&]() {
2012 return outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#output..writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(writeBuffer).attachcxx . . $ kj/Promise#attach(27d17a82377fab45).(mvcxx . . $ kj/mv(9768e8ef939d477).(writeBuffer));
2013 }).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this, amount]() {
2014 limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit. -= amount;
2015 pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#pumpedSoFar. += amount;
2016 if (limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit. == 0) {
2017 fulfillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfill(b07662a27bd562f9).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#pumpedSoFar.);
2018 }
2019 }).eagerlyEvaluatecxx . . $ kj/Promise#eagerlyEvaluate(2be579741f6bb3d).([this](Exceptioncxx . . $ kj/Exception#&& exception) {
2020 rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#reject(c33f37f983fdaa7c).(mvcxx . . $ kj/mv(9768e8ef939d477).(exception));
2021 });
2022
2023 return cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#canceler..wrapcxx . . $ kj/Canceler#wrap(bd1261f88dfd8aae).(mvcxx . . $ kj/mv(9768e8ef939d477).(promise)).catch_cxx . . $ kj/Promise#catch_(2be579741f6bb3d).([](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&&) {});
2024 } else KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(reason, stoppage) {
2025 if (reason->iscxx . . $ kj/OneOf#is(50ce9a9e25b4a850).<Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#>()) {
2026 // Unlike in the read case, it makes more sense to immediately propagate exceptions to the
2027 // pump promise rather than show it a "short pump".
2028 fulfillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#fulfill(b07662a27bd562f9).(pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#pumpedSoFar.);
2029 } else {
2030 rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#SinkBase#reject(c33f37f983fdaa7c).(cpcxx . . $ kj/cp(a09425ded2739bff).(reason->getcxx . . $ kj/OneOf#get(4111f073734757b).<Exceptioncxx . . $ kj/Exception#>()));
2031 }
2032 }
2033
2034 return READY_NOWcxx . . $ kj/READY_NOW.;
2035 }
2036
2037 Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#need(994e2decc18b1e76).() override { return Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# { 1, limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit. }; }
2038
2039 private:
2040 AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& outputcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#output.;
2041 uint64_tcxx . . $ uint64_t# limitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#limit.;
2042 // Arguments to the outer pumpTo() call, decremented after every buffer consumption.
2043 //
2044 // Equal to zero once fulfiller has been fulfilled/rejected.
2045
2046 uint64_tcxx . . $ uint64_t# pumpedSoFarcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#pumpedSoFar. = 0;
2047 // End result of the outer pumpTo().
2048
2049 Cancelercxx . . $ kj/Canceler# cancelercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#PumpSink#canceler.;
2050 // When the pump is canceled, we also need to cancel any write operations in flight.
2051 };
2052
2053 // =====================================================================================
2054
2055 Maybecxx . . $ kj/Maybe#<Sinkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#::Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#> analyzeSinkscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#analyzeSinks(76f6bdf83d3fb32).() {
2056 // Return nullptr if there are no sinks at all. Otherwise, return the largest `minBytes` and the
2057 // smallest `maxBytes` requested by any sink. The pull loop will use these values to calculate
2058 // the optimal buffer size for the next inner read, so that a minimum amount of data is buffered
2059 // at any given time.
2060
2061 uint64_tcxx . . $ uint64_t# minBytes = 0;
2062 uint64_tcxx . . $ uint64_t# maxBytes = kjcxx . . $ kj/::maxValuecxx . . $ kj/maxValue.;
2063
2064 uintcxx . . $ kj/uint# nSinks = 0;
2065
2066 for (auto& branch: branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.) {
2067 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(sink, branch.sink) {
2068 ++nSinks;
2069 auto need = sink->needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#need(994e2decc18b1e76).();
2070 minBytes = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(minBytes, need.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#minBytes.);
2071 maxBytes = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(maxBytes, need.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes.);
2072 }
2073 }
2074
2075 if (nSinks > 0) {
2076 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(minBytes > 0);
2077 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(maxBytes > 0, "sink was filled but did not detach");
2078
2079 // Sinks may report non-overlapping needs.
2080 maxBytes = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(minBytes, maxBytes);
2081
2082 return Sinkcxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70).::Needcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need# { minBytes, maxBytes };
2083 }
2084
2085 // No active sinks.
2086 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2087 }
2088
2089 void ensurePullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#ensurePulling(49f6e7a06ebc5aa8).() {
2090 if (!pullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pulling.) {
2091 pullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pulling. = true;
2092 UnwindDetectorcxx . . $ kj/UnwindDetector# unwindcxx . . $ kj/UnwindDetector#UnwindDetector(49f6e7a06ebc5aa8).;
2093 KJ_DEFERcxx . . $ `src/kj/common.h:2043:9`!(if (unwind.isUnwinding()) pulling = false);
2094 pullPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullPromise. =cxx . . $ kj/Promise#`operator=`(83311e5543e7d716). pullcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pull(542ddddf9229d39a).();
2095 }
2096 }
2097
2098 Promisecxx . . $ kj/Promise#<void> pullcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pull(542ddddf9229d39a).() {
2099 return pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).().eagerlyEvaluatecxx . . $ kj/Promise#eagerlyEvaluate(2be579741f6bb3d).([this](Exceptioncxx . . $ kj/Exception#&& exception) {
2100 // Exception from our loop, not from inner tryRead(). Something is broken; tell everybody!
2101 pullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pulling. = false;
2102 for (auto& branch: branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.) {
2103 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(sink, branch.sink) {
2104 sink->rejectcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#reject(c33f37f983fdaa7c).(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(FAILED, "Exception in tee loop", exception));
2105 }
2106 }
2107 });
2108 }
2109
2110 constexpr static size_t MAX_BLOCK_SIZEcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#MAX_BLOCK_SIZE. = 1 << 14; // 16k
2111
2112 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#inner.;
2113 const uint64_tcxx . . $ uint64_t# bufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#bufferSizeLimit. = kjcxx . . $ kj/::maxValuecxx . . $ kj/maxValue.;
2114 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> lengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#length.;
2115 Listcxx . . $ kj/List#<Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#, &Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#::linkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#link.> branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.;
2116 Maybecxx . . $ kj/Maybe#<Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#> stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage.;
2117 Promisecxx . . $ kj/Promise#<void> pullPromisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullPromise. = READY_NOWcxx . . $ kj/READY_NOW.;
2118 bool pullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pulling. = false;
2119
2120 private:
2121 Promisecxx . . $ kj/Promise#<void> pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).() {
2122 // Use evalLater() so that two pump sinks added on the same turn of the event loop will not
2123 // cause buffering.
2124 return evalLatercxx . . $ kj/evalLater(2a9d78fa55ded97b).([this] {
2125 // Attempt to fill any sinks that exist.
2126
2127 Vectorcxx . . $ kj/Vector#<Promisecxx . . $ kj/Promise#<void>> promisescxx . . $ kj/Vector#Vector(49f6e7a06ebc5aa8).;
2128
2129 for (auto& branch: branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.) {
2130 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(sink, branch.sink) {
2131 promises.addcxx . . $ kj/Vector#add(7f9966f43a57f391).(sink->fillcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#fill(c63e5418c7ac6f55).(branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer., stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage.));
2132 }
2133 }
2134
2135 // Respect the greatest of the sinks' backpressures.
2136 return joinPromisescxx . . $ kj/joinPromises(d1fd7d3d2dc861d3).(promises.releaseAsArraycxx . . $ kj/Vector#releaseAsArray(dcb0cb35f23a4119).());
2137 }).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() -> Promisecxx . . $ kj/Promise#<void> {
2138 // Check to see whether we need to perform an inner read.
2139
2140 auto need = analyzeSinkscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#analyzeSinks(76f6bdf83d3fb32).();
2141
2142 if (need ==cxx . . $ kj/Maybe#`operator==`(b102b25da64d45e5). nullptr) {
2143 // No more sinks, stop pulling.
2144 pullingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pulling. = false;
2145 return READY_NOWcxx . . $ kj/READY_NOW.;
2146 }
2147
2148 if (stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage. !=cxx . . $ kj/Maybe#`operator!=`(b102b25da64d45e5). nullptr) {
2149 // We're eof or errored, don't read, but loop so we can fill the sink(s).
2150 return pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).();
2151 }
2152
2153 auto& n = KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(need);
2154
2155 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(n.minBytes > 0);
2156
2157 // We must perform an inner read.
2158
2159 // We'd prefer not to explode our buffer, if that's cool. We cap `maxBytes` to the buffer size
2160 // limit or our builtin MAX_BLOCK_SIZE, whichever is smaller. But, we make sure `maxBytes` is
2161 // still >= `minBytes`.
2162 n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes. = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes., MAX_BLOCK_SIZEcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#MAX_BLOCK_SIZE.);
2163 n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes. = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes., bufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#bufferSizeLimit.);
2164 n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes. = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(n.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#minBytes., n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes.);
2165 for (auto& branch: branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.) {
2166 // TODO(perf): buffer.size() is O(n) where n = # of individual heap-allocated byte arrays.
2167 if (branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..sizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#size(fe4d2d262d4164a8).() + n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes. > bufferSizeLimitcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#bufferSizeLimit.) {
2168 stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage. =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#(KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(FAILED, "tee buffer size limit exceeded"));
2169 return pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).();
2170 }
2171 }
2172 auto heapBuffer = heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<bytecxx . . $ kj/byte#>(n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes.);
2173
2174 // gcc 4.9 quirk: If I don't hoist this into a separate variable and instead call
2175 //
2176 // inner->tryRead(heapBuffer.begin(), n.minBytes, heapBuffer.size())
2177 //
2178 // `heapBuffer` seems to get moved into the lambda capture before the arguments to `tryRead()`
2179 // are evaluated, meaning `inner` sees a nullptr destination. Bizarrely, `inner` sees the
2180 // correct value for `heapBuffer.size()`... I dunno, man.
2181 auto destination = heapBuffer.begincxx . . $ kj/Array#begin(155dc7f103cdb9db).();
2182
2183 return kjcxx . . $ kj/::evalNowcxx . . $ kj/evalNow(2a9d78fa55ded97b).([&]() { return innercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#inner.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(destination, n.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#minBytes., n.maxBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#maxBytes.); })
2184 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this, heapBuffer = mvcxx . . $ kj/Array#Array(d736060a6fd4d37e).(heapBuffer), minBytes = n.minBytescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Sink#Need#minBytes.](size_t amount) mutable
2185 -> Promisecxx . . $ kj/Promise#<void> {
2186 lengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#length. =cxx . . $ kj/Maybe#`operator=`(97cdbe1ef4a882e7). lengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#length..mapcxx . . $ kj/Maybe#map(15cd17b8f10d1038).([amount](uint64_tcxx . . $ uint64_t# n) {
2187 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(n >= amount);
2188 return n - amount;
2189 });
2190
2191 if (amount < heapBuffer.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).()) {
2192 heapBuffer =cxx . . $ kj/Array#`operator=`(4e73d5a16a77c634). heapBuffer.slicecxx . . $ kj/Array#slice(671e3291ea40e62f).(0, amount).attachcxx . . $ kj/ArrayPtr#attach(3c11de3c603ad421).(mvcxx . . $ kj/mv(9768e8ef939d477).(heapBuffer));
2193 }
2194
2195 KJ_ASSERTcxx . . $ `src/kj/debug.h:359:9`!(stoppage == nullptr);
2196 Maybecxx . . $ kj/Maybe#<ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#>> bufferPtr = nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2197 for (auto& branch: branchescxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#branches.) {
2198 // Prefer to move the buffer into the receiving branch's deque, rather than memcpy.
2199 //
2200 // TODO(perf): For the 2-branch case, this is fine, since the majority of the time
2201 // only one buffer will be in use. If we generalize to the n-branch case, this would
2202 // become memcpy-heavy.
2203 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(ptr, bufferPtr) {
2204 branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..producecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#produce(5fedcad8c6f5b64a).(heapArraycxx . . $ kj/heapArray(d3d2edcc5a346da7).(*ptr));
2205 } else {
2206 bufferPtr =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#>(heapBuffer);
2207 branch.buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#buffer..producecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#produce(5fedcad8c6f5b64a).(mvcxx . . $ kj/Array#Array(d736060a6fd4d37e).(heapBuffer));
2208 }
2209 }
2210
2211 if (amount < minBytes) {
2212 // Short read, EOF.
2213 stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage. =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#(Eofcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Eof#());
2214 }
2215
2216 return pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).();
2217 }, [this](Exceptioncxx . . $ kj/Exception#&& exception) {
2218 // Exception from the inner tryRead(). Propagate.
2219 stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#stoppage. =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). Stoppagecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Stoppage#(mvcxx . . $ kj/mv(9768e8ef939d477).(exception));
2220 return pullLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#pullLoop(542ddddf9229d39a).();
2221 });
2222 });
2223 }
2224 };
2225
2226 constexpr size_t AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::MAX_BLOCK_SIZEcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#MAX_BLOCK_SIZE.;
2227
2228 uint64_tcxx . . $ uint64_t# AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#::consumecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#consume(50c90a1416dd0f03).(ArrayPtrcxx . . $ kj/ArrayPtr#<bytecxx . . $ kj/byte#>& readBuffer, size_t& minBytes) {
2229 uint64_tcxx . . $ uint64_t# totalAmount = 0;
2230
2231 while (readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && !bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..emptycxx . . $ std/deque#empty(3482b152b9333168).()) {
2232 auto& bytes = bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).();
2233 auto amount = kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).(), readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
2234 memcpy(readBuffer.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).(), bytes.begincxx . . $ kj/Array#begin(155dc7f103cdb9db).(), amount);
2235 totalAmount += amount;
2236
2237 readBuffer =cxx . . $ kj/ArrayPtr#`operator=`(d8484f2dc887c4f0). readBuffer.slicecxx . . $ kj/ArrayPtr#slice(2c7e4e1cf603d8fe).(amount, readBuffer.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
2238 minBytes -= kjcxx . . $ kj/::mincxx . . $ kj/min(4af833f8d939a8d2).(amount, minBytes);
2239
2240 if (amount == bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).()) {
2241 bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..pop_frontcxx . . $ std/deque#pop_front(ced63f7c635d850d).();
2242 } else {
2243 bytes =cxx . . $ kj/Array#`operator=`(4e73d5a16a77c634). heapArraycxx . . $ kj/heapArray(d3d2edcc5a346da7).(bytes.slicecxx . . $ kj/Array#slice(671e3291ea40e62f).(amount, bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).()));
2244 return totalAmount;
2245 }
2246 }
2247
2248 return totalAmount;
2249 }
2250
2251 void AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#::producecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#produce(5fedcad8c6f5b64a).(Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#> bytes) {
2252 bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..push_backcxx . . $ std/deque#push_back(fe7a8a4d1eddb70).(mvcxx . . $ kj/mv(9768e8ef939d477).(bytes));
2253 }
2254
2255 Arraycxx . . $ kj/Array#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#::asArraycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#asArray(2db0eeaf38c966e1).(
2256 uint64_tcxx . . $ uint64_t# maxBytes, uint64_tcxx . . $ uint64_t#& amount) {
2257 amount = 0;
2258
2259 Vectorcxx . . $ kj/Vector#<ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> bufferscxx . . $ kj/Vector#Vector(49f6e7a06ebc5aa8).;
2260 Vectorcxx . . $ kj/Vector#<Arraycxx . . $ kj/Array#<bytecxx . . $ kj/byte#>> ownBufferscxx . . $ kj/Vector#Vector(49f6e7a06ebc5aa8).;
2261
2262 while (maxBytes > 0 && !bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..emptycxx . . $ std/deque#empty(3482b152b9333168).()) {
2263 auto& bytes = bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).();
2264
2265 if (bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).() <= maxBytes) {
2266 amount += bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
2267 maxBytes -= bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
2268
2269 buffers.addcxx . . $ kj/Vector#add(7f9966f43a57f391).(bytes);
2270 ownBuffers.addcxx . . $ kj/Vector#add(7f9966f43a57f391).(mvcxx . . $ kj/mv(9768e8ef939d477).(bytes));
2271
2272 bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..pop_frontcxx . . $ std/deque#pop_front(ced63f7c635d850d).();
2273 } else {
2274 auto ownBytes = heapArraycxx . . $ kj/heapArray(d3d2edcc5a346da7).(bytes.slicecxx . . $ kj/Array#slice(671e3291ea40e62f).(0, maxBytes));
2275 buffers.addcxx . . $ kj/Vector#add(7f9966f43a57f391).(ownBytes);
2276 ownBuffers.addcxx . . $ kj/Vector#add(7f9966f43a57f391).(mvcxx . . $ kj/mv(9768e8ef939d477).(ownBytes));
2277
2278 bytes =cxx . . $ kj/Array#`operator=`(4e73d5a16a77c634). heapArraycxx . . $ kj/heapArray(d3d2edcc5a346da7).(bytes.slicecxx . . $ kj/Array#slice(671e3291ea40e62f).(maxBytes, bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).()));
2279
2280 amount += maxBytes;
2281 maxBytes = 0;
2282 }
2283 }
2284
2285
2286 if (buffers.sizecxx . . $ kj/Vector#size(fe4d2d262d4164a8).() > 0) {
2287 return bufferscxx . . $ kj/Array#Array(5712942556f34fe)..releaseAsArraycxx . . $ kj/Vector#releaseAsArray(dcb0cb35f23a4119).().attachcxx . . $ kj/Array#attach(a28f075cb7f6e901).(mvcxx . . $ kj/mv(9768e8ef939d477).(ownBuffers));
2288 }
2289
2290 return {cxx . . $ kj/Array#Array(49f6e7a06ebc5aa8).};
2291 }
2292
2293 bool AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#::emptycxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#empty(50ce9a9e25b4a850).() const {
2294 return bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList..emptycxx . . $ std/deque#empty(3482b152b9333168).();
2295 }
2296
2297 uint64_tcxx . . $ uint64_t# AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Buffercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#::sizecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#size(fe4d2d262d4164a8).() const {
2298 uint64_tcxx . . $ uint64_t# result = 0;
2299
2300 for (auto& bytes: bufferListcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Buffer#bufferList.) {
2301 result += bytes.sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).();
2302 }
2303
2304 return result;
2305 }
2306
2307 } // namespace
2308
2309 Teecxx . . $ kj/Tee# newTeecxx . . $ kj/newTee(70c932a6f67d0f25).(Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> input, uint64_tcxx . . $ uint64_t# limit) {
2310 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(t, input->tryTee(limit)) {
2311 return { { mvcxx . . $ kj/mv(9768e8ef939d477).(input), mvcxx . . $ kj/mv(9768e8ef939d477).(*cxx . . $ kj/_/OwnOwn#`operator*`(33142f91ea399467).t) }};
2312 }
2313
2314 auto impl = refcountedcxx . . $ kj/refcounted(bae2fec6325dc41a).<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#>(mvcxx . . $ kj/mv(9768e8ef939d477).(input), limit);
2315 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> branch1 = heapcxx . . $ kj/Own#Own(97d08cb47632509f).<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#>(addRefcxx . . $ kj/addRef(2985e049e023da4).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).impl));
2316 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> branch2 = heapcxx . . $ kj/Own#Own(97d08cb47632509f).<AsyncTeecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#::Branchcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AsyncTee#Branch#>(mvcxx . . $ kj/mv(9768e8ef939d477).(impl));
2317 return { { mvcxx . . $ kj/mv(9768e8ef939d477).(branch1), mvcxx . . $ kj/mv(9768e8ef939d477).(branch2) } };
2318 }
2319
2320 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
2321
2322 class PromisedAsyncIoStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream# final: public kjcxx . . $ kj/::AsyncIoStreamcxx . . $ kj/AsyncIoStream#, private kjcxx . . $ kj/::TaskSetcxx . . $ kj/TaskSet#::ErrorHandlercxx . . $ kj/TaskSet#ErrorHandler# {
2323 // An AsyncIoStream which waits for a promise to resolve then forwards all calls to the promised
2324 // stream.
2325
2326 public:
2327 PromisedAsyncIoStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#PromisedAsyncIoStream(e93952c0f6efd77c).(kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> promise)
2328 : promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise.(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this](kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> result) {
2329 streamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#stream. =cxx . . $ kj/Maybe#`operator=`(1122f447bec8131d). kjcxx . . $ kj/Maybe#Maybe(d80f67c6086917eb).::mvcxx . . $ kj/mv(9768e8ef939d477).(result);
2330 }).forkcxx . . $ kj/Promise#fork(2ed7963d7a1857b8).()),
2331 taskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tasks.(*this) {}
2332
2333 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<size_t> readcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#read(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
2334 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2335 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->readcxx . . $ kj/AsyncInputStream#read(1d893319628a2258).(buffer, minBytes, maxBytes);
2336 } else {
2337 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,buffer,minBytes,maxBytes]() {
2338 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).readcxx . . $ kj/AsyncInputStream#read(1d893319628a2258).(buffer, minBytes, maxBytes);
2339 });
2340 }
2341 }
2342 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<size_t> tryReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) override {
2343 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2344 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes);
2345 } else {
2346 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,buffer,minBytes,maxBytes]() {
2347 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).tryReadcxx . . $ kj/AsyncInputStream#tryRead(1d893319628a2258).(buffer, minBytes, maxBytes);
2348 });
2349 }
2350 }
2351
2352 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> tryGetLengthcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tryGetLength(b0ae5156aeb9187c).() override {
2353 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2354 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->tryGetLengthcxx . . $ kj/AsyncInputStream#tryGetLength(b0ae5156aeb9187c).();
2355 } else {
2356 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2357 }
2358 }
2359
2360 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#> pumpTocxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#pumpTo(779d39587ccc1d6c).(kjcxx . . $ kj/::AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#& output, uint64_tcxx . . $ uint64_t# amount) override {
2361 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2362 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(output, amount);
2363 } else {
2364 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&output,amount]() {
2365 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(output, amount);
2366 });
2367 }
2368 }
2369
2370 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
2371 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2372 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffer, size);
2373 } else {
2374 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,buffer,size]() {
2375 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffer, size);
2376 });
2377 }
2378 }
2379 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#write(251ec43b44baa62).(kjcxx . . $ kj/::ArrayPtrcxx . . $ kj/ArrayPtr#<const kjcxx . . $ kj/::ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
2380 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2381 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces);
2382 } else {
2383 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,pieces]() {
2384 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces);
2385 });
2386 }
2387 }
2388
2389 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tryPumpFrom(6d2b023c494552c3).(
2390 kjcxx . . $ kj/::AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount = kjcxx . . $ kj/::maxValuecxx . . $ kj/maxValue.) override {
2391 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2392 // Call input.pumpTo() on the resolved stream instead, so that if it does some dynamic_casts
2393 // or whatnot to detect stream types it can retry those on the inner stream.
2394 return inputcxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70)..pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).*s, amount);
2395 } else {
2396 return promisecxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70)..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&input,amount]() {
2397 // Here we actually have no choice but to call input.pumpTo() because if we called
2398 // tryPumpFrom(input, amount) and it returned nullptr, what would we do? It's too late for
2399 // us to return nullptr. But the thing about dynamic_cast also applies.
2400 return input.pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream), amount);
2401 });
2402 }
2403 }
2404
2405 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#whenWriteDisconnected(542ddddf9229d39a).() override {
2406 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2407 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->whenWriteDisconnectedcxx . . $ kj/AsyncOutputStream#whenWriteDisconnected(542ddddf9229d39a).();
2408 } else {
2409 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
2410 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).whenWriteDisconnectedcxx . . $ kj/AsyncOutputStream#whenWriteDisconnected(542ddddf9229d39a).();
2411 }, [](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) -> kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> {
2412 if (e.getTypecxx . . $ kj/Exception#getType(981cd29bd1003f36).() == kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#::Typecxx . . $ kj/Exception#Type#::DISCONNECTEDcxx . . $ kj/Exception#Type#DISCONNECTED.) {
2413 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
2414 } else {
2415 return kjcxx . . $ kj/Promise#Promise(c33f37f983fdaa7c).::mvcxx . . $ kj/mv(9768e8ef939d477).(e);
2416 }
2417 });
2418 }
2419 }
2420
2421 void shutdownWritecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#shutdownWrite(49f6e7a06ebc5aa8).() override {
2422 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2423 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->shutdownWritecxx . . $ kj/AsyncIoStream#shutdownWrite(49f6e7a06ebc5aa8).();
2424 } else {
2425 taskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tasks..addcxx . . $ kj/TaskSet#add(4b4073c8e3e9a341).(promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
2426 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).shutdownWritecxx . . $ kj/AsyncIoStream#shutdownWrite(49f6e7a06ebc5aa8).();
2427 }));
2428 }
2429 }
2430
2431 void abortReadcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#abortRead(49f6e7a06ebc5aa8).() override {
2432 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2433 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->abortReadcxx . . $ kj/AsyncIoStream#abortRead(49f6e7a06ebc5aa8).();
2434 } else {
2435 taskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tasks..addcxx . . $ kj/TaskSet#add(4b4073c8e3e9a341).(promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
2436 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).abortReadcxx . . $ kj/AsyncIoStream#abortRead(49f6e7a06ebc5aa8).();
2437 }));
2438 }
2439 }
2440
2441 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<int> getFdcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#getFd(4e8e5944c880cc1f).() const override {
2442 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2443 return s->getcxx . . $ kj/Own#get(1016ee5406d91ab9).()->getFdcxx . . $ kj/AsyncIoStream#getFd(4e8e5944c880cc1f).();
2444 } else {
2445 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2446 }
2447 }
2448
2449 private:
2450 kjcxx . . $ kj/::ForkedPromisecxx . . $ kj/ForkedPromise#<void> promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#promise.;
2451 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> streamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#stream.;
2452 kjcxx . . $ kj/::TaskSetcxx . . $ kj/TaskSet# taskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#tasks.;
2453
2454 void taskFailedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#taskFailed(c33f37f983fdaa7c).(kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& exception) override {
2455 KJ_LOGcxx . . $ `src/kj/debug.h:219:9`!(ERROR, exception);
2456 }
2457 };
2458
2459 class PromisedAsyncOutputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream# final: public kjcxx . . $ kj/::AsyncOutputStreamcxx . . $ kj/AsyncOutputStream# {
2460 // An AsyncOutputStream which waits for a promise to resolve then forwards all calls to the
2461 // promised stream.
2462 //
2463 // TODO(cleanup): Can this share implementation with PromiseIoStream? Seems hard.
2464
2465 public:
2466 PromisedAsyncOutputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#PromisedAsyncOutputStream(99d6dac8566aa596).(kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#>> promise)
2467 : promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#promise.(promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this](kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#> result) {
2468 streamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#stream. =cxx . . $ kj/Maybe#`operator=`(1122f447bec8131d). kjcxx . . $ kj/Maybe#Maybe(d80f67c6086917eb).::mvcxx . . $ kj/mv(9768e8ef939d477).(result);
2469 }).forkcxx . . $ kj/Promise#fork(2ed7963d7a1857b8).()) {}
2470
2471 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#write(7ee344f2bd176b7a).(const void* buffer, size_t size) override {
2472 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2473 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffer, size);
2474 } else {
2475 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,buffer,size]() {
2476 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/AsyncOutputStream#write(7ee344f2bd176b7a).(buffer, size);
2477 });
2478 }
2479 }
2480 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> writecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#write(251ec43b44baa62).(kjcxx . . $ kj/::ArrayPtrcxx . . $ kj/ArrayPtr#<const kjcxx . . $ kj/::ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) override {
2481 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2482 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces);
2483 } else {
2484 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,pieces]() {
2485 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).writecxx . . $ kj/AsyncOutputStream#write(251ec43b44baa62).(pieces);
2486 });
2487 }
2488 }
2489
2490 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<uint64_tcxx . . $ uint64_t#>> tryPumpFromcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#tryPumpFrom(6d2b023c494552c3).(
2491 kjcxx . . $ kj/::AsyncInputStreamcxx . . $ kj/AsyncInputStream#& input, uint64_tcxx . . $ uint64_t# amount = kjcxx . . $ kj/::maxValuecxx . . $ kj/maxValue.) override {
2492 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2493 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->tryPumpFromcxx . . $ kj/AsyncOutputStream#tryPumpFrom(6d2b023c494552c3).(input, amount);
2494 } else {
2495 return promisecxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70)..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this,&input,amount]() {
2496 // Call input.pumpTo() on the resolved stream instead.
2497 return input.pumpTocxx . . $ kj/AsyncInputStream#pumpTo(779d39587ccc1d6c).(*cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream), amount);
2498 });
2499 }
2500 }
2501
2502 Promisecxx . . $ kj/Promise#<void> whenWriteDisconnectedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#whenWriteDisconnected(542ddddf9229d39a).() override {
2503 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(s, stream) {
2504 return s->getcxx . . $ kj/Own#get(155dc7f103cdb9db).()->whenWriteDisconnectedcxx . . $ kj/AsyncOutputStream#whenWriteDisconnected(542ddddf9229d39a).();
2505 } else {
2506 return promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#promise..addBranchcxx . . $ kj/ForkedPromise#addBranch(5668e015fc35486c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this]() {
2507 return KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(stream)->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).whenWriteDisconnectedcxx . . $ kj/AsyncOutputStream#whenWriteDisconnected(542ddddf9229d39a).();
2508 }, [](kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#&& e) -> kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<void> {
2509 if (e.getTypecxx . . $ kj/Exception#getType(981cd29bd1003f36).() == kjcxx . . $ kj/::Exceptioncxx . . $ kj/Exception#::Typecxx . . $ kj/Exception#Type#::DISCONNECTEDcxx . . $ kj/Exception#Type#DISCONNECTED.) {
2510 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
2511 } else {
2512 return kjcxx . . $ kj/Promise#Promise(c33f37f983fdaa7c).::mvcxx . . $ kj/mv(9768e8ef939d477).(e);
2513 }
2514 });
2515 }
2516 }
2517
2518 private:
2519 kjcxx . . $ kj/::ForkedPromisecxx . . $ kj/ForkedPromise#<void> promisecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#promise.;
2520 kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<kjcxx . . $ kj/::Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#>> streamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#stream.;
2521 };
2522
2523 } // namespace
2524
2525 Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#> newPromisedStreamcxx . . $ kj/newPromisedStream(4a079047cb09843a).(Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#>> promise) {
2526 return heapcxx . . $ kj/Own#Own(97d08cb47632509f).<PromisedAsyncOutputStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncOutputStream#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(promise));
2527 }
2528 Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> newPromisedStreamcxx . . $ kj/newPromisedStream(343a7ea744660af).(Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> promise) {
2529 return heapcxx . . $ kj/Own#Own(97d08cb47632509f).<PromisedAsyncIoStreamcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/PromisedAsyncIoStream#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(promise));
2530 }
2531
2532 Promisecxx . . $ kj/Promise#<void> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::writeWithFdscxx . . $ kj/AsyncCapabilityStream#writeWithFds(bed6b53d5b2af5df).(
2533 ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#> data, ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> moreData,
2534 ArrayPtrcxx . . $ kj/ArrayPtr#<const AutoCloseFdcxx . . $ kj/AutoCloseFd#> fds) {
2535 // HACK: AutoCloseFd actually contains an `int` under the hood. We can reinterpret_cast to avoid
2536 // unnecessary memory allocation.
2537 static_assert(sizeof(AutoCloseFdcxx . . $ kj/AutoCloseFd#) == sizeof(int), "this optimization won't work");
2538 auto intArray = arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<const int*>(fds.begincxx . . $ kj/ArrayPtr#begin(155dc7f103cdb9db).()), fds.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).());
2539
2540 // Be extra-paranoid about aliasing rules by injecting a compiler barrier here. Probably
2541 // not necessary but also probably doesn't hurt.
2542 #if _MSC_VER
2543 _ReadWriteBarrier();
2544 #else
2545 __asm__ __volatile__("": : :"memory");
2546 #endif
2547
2548 return writeWithFdscxx . . $ kj/AsyncCapabilityStream#writeWithFds(d5524f9bb452a0e9).(data, moreData, intArray);
2549 }
2550
2551 Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::receiveStreamcxx . . $ kj/AsyncCapabilityStream#receiveStream(4eb035c91da40109).() {
2552 return tryReceiveStreamcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).()
2553 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>&& result)
2554 -> Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> {
2555 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(r, result) {
2556 return kjcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).::mvcxx . . $ kj/mv(9768e8ef939d477).(*r);
2557 } else {
2558 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(FAILED, "EOF when expecting to receive capability");
2559 }
2560 });
2561 }
2562
2563 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::tryReceiveStreamcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).() {
2564 struct ResultHoldercxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder# {
2565 bytecxx . . $ kj/byte# bcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#b.;
2566 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#> streamcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#stream.;
2567 };
2568 auto result = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<ResultHoldercxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#>();
2569 auto promise = tryReadWithStreamscxx . . $ kj/AsyncCapabilityStream#tryReadWithStreams(ff85abfb9995b3c3).(&result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).bcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#b., 1, 1, &result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).streamcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#stream., 1);
2570 return promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([result = kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(result)](ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# actual) mutable
2571 -> Maybecxx . . $ kj/Maybe#<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>> {
2572 if (actual.byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. == 0) {
2573 return nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
2574 }
2575
2576 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(actual.capCount == 1,
2577 "expected to receive a capability (e.g. file descriptor via SCM_RIGHTS), but didn't") {
2578 return nullptrcxx . . $ kj/Maybe#Maybe(6d988fd07f070dfc).;
2579 }
2580
2581 return kjcxx . . $ kj/Maybe#Maybe(d80f67c6086917eb).::mvcxx . . $ kj/mv(9768e8ef939d477).(result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).streamcxx . . $ kj/AsyncCapabilityStream#tryReceiveStream(bac8e2136e48a83a).ResultHolder#stream.);
2582 });
2583 }
2584
2585 Promisecxx . . $ kj/Promise#<void> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::sendStreamcxx . . $ kj/AsyncCapabilityStream#sendStream(61615e2e2ef9a91d).(Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#> stream) {
2586 static constexpr bytecxx . . $ kj/byte# b = 0;
2587 auto streams = kjcxx . . $ kj/::heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>>(1);
2588 streams[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).0] =cxx . . $ kj/Own#`operator=`(e96ca0ce8edb0ed). kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(stream);
2589 return writeWithStreamscxx . . $ kj/AsyncCapabilityStream#writeWithStreams(73343d092f4f66e6).(arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(&b, 1), nullptrcxx . . $ kj/ArrayPtr#ArrayPtr(49b4c06ce5d54a60)., kjcxx . . $ kj/Array#Array(d736060a6fd4d37e).::mvcxx . . $ kj/mv(9768e8ef939d477).(streams));
2590 }
2591
2592 Promisecxx . . $ kj/Promise#<AutoCloseFdcxx . . $ kj/AutoCloseFd#> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::receiveFdcxx . . $ kj/AsyncCapabilityStream#receiveFd(45b759e682c2ad44).() {
2593 return tryReceiveFdcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Maybecxx . . $ kj/Maybe#<AutoCloseFdcxx . . $ kj/AutoCloseFd#>&& result) -> Promisecxx . . $ kj/Promise#<AutoCloseFdcxx . . $ kj/AutoCloseFd#> {
2594 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(r, result) {
2595 return kjcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).::mvcxx . . $ kj/mv(9768e8ef939d477).(*r);
2596 } else {
2597 return KJ_EXCEPTIONcxx . . $ `src/kj/debug.h:311:9`!(FAILED, "EOF when expecting to receive capability");
2598 }
2599 });
2600 }
2601
2602 kjcxx . . $ kj/::Promisecxx . . $ kj/Promise#<kjcxx . . $ kj/::Maybecxx . . $ kj/Maybe#<AutoCloseFdcxx . . $ kj/AutoCloseFd#>> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::tryReceiveFdcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).() {
2603 struct ResultHoldercxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder# {
2604 bytecxx . . $ kj/byte# bcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#b.;
2605 AutoCloseFdcxx . . $ kj/AutoCloseFd# fdcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#fd.;
2606 };
2607 auto result = kjcxx . . $ kj/::heapcxx . . $ kj/heap(bae2fec6325dc41a).<ResultHoldercxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#>();
2608 auto promise = tryReadWithFdscxx . . $ kj/AsyncCapabilityStream#tryReadWithFds(68a0207625b41c85).(&result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).bcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#b., 1, 1, &result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).fdcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#fd., 1);
2609 return promise.thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([result = kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(result)](ReadResultcxx . . $ kj/AsyncCapabilityStream#ReadResult# actual) mutable
2610 -> Maybecxx . . $ kj/Maybe#<AutoCloseFdcxx . . $ kj/AutoCloseFd#> {
2611 if (actual.byteCountcxx . . $ kj/AsyncCapabilityStream#ReadResult#byteCount. == 0) {
2612 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2613 }
2614
2615 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(actual.capCount == 1,
2616 "expected to receive a file descriptor (e.g. via SCM_RIGHTS), but didn't") {
2617 return nullptrcxx . . $ kj/Maybe#Maybe(49b4c06ce5d54a60).;
2618 }
2619
2620 return kjcxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70).::mvcxx . . $ kj/mv(9768e8ef939d477).(result->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).fdcxx . . $ kj/AsyncCapabilityStream#tryReceiveFd(77b82d421c010c0c).ResultHolder#fd.);
2621 });
2622 }
2623
2624 Promisecxx . . $ kj/Promise#<void> AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#::sendFdcxx . . $ kj/AsyncCapabilityStream#sendFd(e3a3005101f46613).(int fd) {
2625 static constexpr bytecxx . . $ kj/byte# b = 0;
2626 auto fds = kjcxx . . $ kj/::heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<int>(1);
2627 fds[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).0] = fd;
2628 auto promise = writeWithFdscxx . . $ kj/AsyncCapabilityStream#writeWithFds(d5524f9bb452a0e9).(arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(&b, 1), nullptrcxx . . $ kj/ArrayPtr#ArrayPtr(49b4c06ce5d54a60)., fds);
2629 return promise.attachcxx . . $ kj/Promise#attach(27d17a82377fab45).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(fds));
2630 }
2631
2632 void AsyncIoStreamcxx . . $ kj/AsyncIoStream#::getsockoptcxx . . $ kj/AsyncIoStream#getsockopt(8f49a46285e37e42).(int level, int option, void* value, uintcxx . . $ kj/uint#* length) {
2633 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2634 }
2635 void AsyncIoStreamcxx . . $ kj/AsyncIoStream#::setsockoptcxx . . $ kj/AsyncIoStream#setsockopt(beb4e39792953a71).(int level, int option, const void* value, uintcxx . . $ kj/uint# length) {
2636 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { break; }
2637 }
2638 void AsyncIoStreamcxx . . $ kj/AsyncIoStream#::getsocknamecxx . . $ kj/AsyncIoStream#getsockname(553581679dd6ad96).(struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint#* length) {
2639 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2640 }
2641 void AsyncIoStreamcxx . . $ kj/AsyncIoStream#::getpeernamecxx . . $ kj/AsyncIoStream#getpeername(553581679dd6ad96).(struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint#* length) {
2642 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2643 }
2644 void ConnectionReceivercxx . . $ kj/ConnectionReceiver#::getsockoptcxx . . $ kj/ConnectionReceiver#getsockopt(8f49a46285e37e42).(int level, int option, void* value, uintcxx . . $ kj/uint#* length) {
2645 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2646 }
2647 void ConnectionReceivercxx . . $ kj/ConnectionReceiver#::setsockoptcxx . . $ kj/ConnectionReceiver#setsockopt(beb4e39792953a71).(int level, int option, const void* value, uintcxx . . $ kj/uint# length) {
2648 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { break; }
2649 }
2650 void ConnectionReceivercxx . . $ kj/ConnectionReceiver#::getsocknamecxx . . $ kj/ConnectionReceiver#getsockname(553581679dd6ad96).(struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint#* length) {
2651 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2652 }
2653 void DatagramPortcxx . . $ kj/DatagramPort#::getsockoptcxx . . $ kj/DatagramPort#getsockopt(8f49a46285e37e42).(int level, int option, void* value, uintcxx . . $ kj/uint#* length) {
2654 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { *length = 0; break; }
2655 }
2656 void DatagramPortcxx . . $ kj/DatagramPort#::setsockoptcxx . . $ kj/DatagramPort#setsockopt(beb4e39792953a71).(int level, int option, const void* value, uintcxx . . $ kj/uint# length) {
2657 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Not a socket.") { break; }
2658 }
2659 Owncxx . . $ kj/Own#<DatagramPortcxx . . $ kj/DatagramPort#> NetworkAddresscxx . . $ kj/NetworkAddress#::bindDatagramPortcxx . . $ kj/NetworkAddress#bindDatagramPort(56f703ddd6c02d40).() {
2660 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Datagram sockets not implemented.");
2661 }
2662 Owncxx . . $ kj/Own#<DatagramPortcxx . . $ kj/DatagramPort#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapDatagramSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapDatagramSocketFd(83507ded3898c1e9).(
2663 Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd# fd, LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#& filter, uintcxx . . $ kj/uint# flags) {
2664 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Datagram sockets not implemented.");
2665 }
2666 #if !_WIN32
2667 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapUnixSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapUnixSocketFd(52708683e3f26a94).(Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd# fd, uintcxx . . $ kj/uint# flags) {
2668 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Unix socket with FD passing not implemented.");
2669 }
2670 #endif
2671 CapabilityPipecxx . . $ kj/CapabilityPipe# AsyncIoProvidercxx . . $ kj/AsyncIoProvider#::newCapabilityPipecxx . . $ kj/AsyncIoProvider#newCapabilityPipe(69844c81ff968e52).() {
2672 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("Capability pipes not implemented.");
2673 }
2674
2675 Owncxx . . $ kj/Own#<AsyncInputStreamcxx . . $ kj/AsyncInputStream#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapInputFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapInputFd(54ab6475d4867775).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2676 return wrapInputFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapInputFd(6cb9dedcaff292d2).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2677 }
2678 Owncxx . . $ kj/Own#<AsyncOutputStreamcxx . . $ kj/AsyncOutputStream#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapOutputFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapOutputFd(7f9b06f652b52fa2).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2679 return wrapOutputFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapOutputFd(db7e3dcededc20d7).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2680 }
2681 Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapSocketFd(524057c3f51850ea).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2682 return wrapSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapSocketFd(d046ab8af8a1f519).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2683 }
2684 #if !_WIN32
2685 Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapUnixSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapUnixSocketFd(3e208c999104e6f0).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2686 return wrapUnixSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapUnixSocketFd(52708683e3f26a94).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2687 }
2688 #endif
2689 Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapConnectingSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapConnectingSocketFd(806c4418fa0f061f).(
2690 OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, const struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint# addrlen, uintcxx . . $ kj/uint# flags) {
2691 return wrapConnectingSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapConnectingSocketFd(137a96e41eb550c4).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), addr, addrlen,
2692 flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2693 }
2694 Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapListenSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapListenSocketFd(112de730e2a47b23).(
2695 OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#& filter, uintcxx . . $ kj/uint# flags) {
2696 return wrapListenSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapListenSocketFd(e55a9a16b9acc62b).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), filter, flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2697 }
2698 Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapListenSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapListenSocketFd(447acb89ca39bdd9).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2699 return wrapListenSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapListenSocketFd(4c0414d39a5b3278).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2700 }
2701 Owncxx . . $ kj/Own#<DatagramPortcxx . . $ kj/DatagramPort#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapDatagramSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapDatagramSocketFd(c158010b80100630).(
2702 OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#& filter, uintcxx . . $ kj/uint# flags) {
2703 return wrapDatagramSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapDatagramSocketFd(83507ded3898c1e9).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), filter, flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2704 }
2705 Owncxx . . $ kj/Own#<DatagramPortcxx . . $ kj/DatagramPort#> LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::wrapDatagramSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapDatagramSocketFd(dc2e0d43b8bcafe2).(OwnFdcxx . . $ kj/LowLevelAsyncIoProvider#OwnFd#&& fd, uintcxx . . $ kj/uint# flags) {
2706 return wrapDatagramSocketFdcxx . . $ kj/LowLevelAsyncIoProvider#wrapDatagramSocketFd(53ad3266582a4826).(reinterpret_cast<Fdcxx . . $ kj/LowLevelAsyncIoProvider#Fd#>(fd.releasecxx . . $ kj/AutoCloseFd#release(b126dc7c1de90089).()), flags | TAKE_OWNERSHIPcxx . . $ kj/LowLevelAsyncIoProvider#TAKE_OWNERSHIP.);
2707 }
2708
2709 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
2710
2711 class DummyNetworkFiltercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/DummyNetworkFilter#: public kjcxx . . $ kj/::LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter# {
2712 public:
2713 bool shouldAllowcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/DummyNetworkFilter#shouldAllow(76befadadad58264).(const struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint# addrlen) override { return true; }
2714 };
2715
2716 } // namespace
2717
2718 LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#& LowLevelAsyncIoProvidercxx . . $ kj/LowLevelAsyncIoProvider#::NetworkFiltercxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#::getAllAllowedcxx . . $ kj/LowLevelAsyncIoProvider#NetworkFilter#getAllAllowed(cef3e9f03b7bfbe4).() {
2719 static DummyNetworkFiltercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/DummyNetworkFilter# result;
2720 return result;
2721 }
2722
2723 // =======================================================================================
2724 // Convenience adapters.
2725
2726 Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> CapabilityStreamConnectionReceivercxx . . $ kj/CapabilityStreamConnectionReceiver#::acceptcxx . . $ kj/CapabilityStreamConnectionReceiver#accept(61a533e69b34abe2).() {
2727 return innercxx . . $ kj/CapabilityStreamConnectionReceiver#inner..receiveStreamcxx . . $ kj/AsyncCapabilityStream#receiveStream(4eb035c91da40109).()
2728 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Owncxx . . $ kj/Own#<AsyncCapabilityStreamcxx . . $ kj/AsyncCapabilityStream#>&& stream) -> Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> {
2729 return kjcxx . . $ kj/Own#Own(97d08cb47632509f).::mvcxx . . $ kj/mv(9768e8ef939d477).(stream);
2730 });
2731 }
2732
2733 Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#> CapabilityStreamConnectionReceivercxx . . $ kj/CapabilityStreamConnectionReceiver#::acceptAuthenticatedcxx . . $ kj/CapabilityStreamConnectionReceiver#acceptAuthenticated(f5454c7a382d7752).() {
2734 return acceptcxx . . $ kj/CapabilityStreamConnectionReceiver#accept(61a533e69b34abe2).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>&& stream) {
2735 return AuthenticatedStreamcxx . . $ kj/AuthenticatedStream# { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(stream), UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#::newInstancecxx . . $ kj/UnknownPeerIdentity#newInstance(652c5475fc6e4300).() };
2736 });
2737 }
2738
2739 uintcxx . . $ kj/uint# CapabilityStreamConnectionReceivercxx . . $ kj/CapabilityStreamConnectionReceiver#::getPortcxx . . $ kj/CapabilityStreamConnectionReceiver#getPort(db52760e79bf9054).() {
2740 return 0;
2741 }
2742
2743 Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> CapabilityStreamNetworkAddresscxx . . $ kj/CapabilityStreamNetworkAddress#::connectcxx . . $ kj/CapabilityStreamNetworkAddress#connect(61a533e69b34abe2).() {
2744 CapabilityPipecxx . . $ kj/CapabilityPipe# pipe;
2745 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(p, provider) {
2746 pipe =cxx . . $ kj/CapabilityPipe#`operator=`(810a18f1503d8fcd). p->newCapabilityPipecxx . . $ kj/AsyncIoProvider#newCapabilityPipe(69844c81ff968e52).();
2747 } else {
2748 pipe =cxx . . $ kj/CapabilityPipe#`operator=`(810a18f1503d8fcd). kjcxx . . $ kj/::newCapabilityPipecxx . . $ kj/newCapabilityPipe(69844c81ff968e52).();
2749 }
2750 auto result = kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe.endscxx . . $ kj/CapabilityPipe#ends.[0]);
2751 return innercxx . . $ kj/CapabilityStreamNetworkAddress#inner..sendStreamcxx . . $ kj/AsyncCapabilityStream#sendStream(61615e2e2ef9a91d).(kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(pipe.endscxx . . $ kj/CapabilityPipe#ends.[1]))
2752 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([result=kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(result)]() mutable {
2753 return Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(result));
2754 });
2755 }
2756 Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#> CapabilityStreamNetworkAddresscxx . . $ kj/CapabilityStreamNetworkAddress#::connectAuthenticatedcxx . . $ kj/CapabilityStreamNetworkAddress#connectAuthenticated(f5454c7a382d7752).() {
2757 return connectcxx . . $ kj/CapabilityStreamNetworkAddress#connect(61a533e69b34abe2).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>&& stream) {
2758 return AuthenticatedStreamcxx . . $ kj/AuthenticatedStream# { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(stream), UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#::newInstancecxx . . $ kj/UnknownPeerIdentity#newInstance(652c5475fc6e4300).() };
2759 });
2760 }
2761 Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#> CapabilityStreamNetworkAddresscxx . . $ kj/CapabilityStreamNetworkAddress#::listencxx . . $ kj/CapabilityStreamNetworkAddress#listen(dbacf5411e921979).() {
2762 return kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<CapabilityStreamConnectionReceivercxx . . $ kj/CapabilityStreamConnectionReceiver#>(innercxx . . $ kj/CapabilityStreamNetworkAddress#inner.);
2763 }
2764
2765 Owncxx . . $ kj/Own#<NetworkAddresscxx . . $ kj/NetworkAddress#> CapabilityStreamNetworkAddresscxx . . $ kj/CapabilityStreamNetworkAddress#::clonecxx . . $ kj/CapabilityStreamNetworkAddress#clone(b81ed4165adc1f30).() {
2766 KJ_UNIMPLEMENTEDcxx . . $ `src/kj/debug.h:273:9`!("can't clone CapabilityStreamNetworkAddress");
2767 }
2768 Stringcxx . . $ kj/String# CapabilityStreamNetworkAddresscxx . . $ kj/CapabilityStreamNetworkAddress#::toStringcxx . . $ kj/CapabilityStreamNetworkAddress#toString(af22d04b00c82e5d).() {
2769 return kjcxx . . $ kj/::strcxx . . $ kj/str(d4f75be60228bbc5).("<CapabilityStreamNetworkAddress>");
2770 }
2771
2772 Promisecxx . . $ kj/Promise#<size_t> FileInputStreamcxx . . $ kj/FileInputStream#::tryReadcxx . . $ kj/FileInputStream#tryRead(1d893319628a2258).(void* buffer, size_t minBytes, size_t maxBytes) {
2773 // Note that our contract with `minBytes` is that we should only return fewer than `minBytes` on
2774 // EOF. A file read will only produce fewer than the requested number of bytes if EOF was reached.
2775 // `minBytes` cannot be greater than `maxBytes`. So, this read satisfies the `minBytes`
2776 // requirement.
2777 size_t result = filecxx . . $ kj/FileInputStream#file..readcxx . . $ kj/ReadableFile#read(1e1fe5e0814d7f5).(offsetcxx . . $ kj/FileInputStream#offset., arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<bytecxx . . $ kj/byte#*>(buffer), maxBytes));
2778 offsetcxx . . $ kj/FileInputStream#offset. += result;
2779 return resultcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).;
2780 }
2781
2782 Maybecxx . . $ kj/Maybe#<uint64_tcxx . . $ uint64_t#> FileInputStreamcxx . . $ kj/FileInputStream#::tryGetLengthcxx . . $ kj/FileInputStream#tryGetLength(b0ae5156aeb9187c).() {
2783 uint64_tcxx . . $ uint64_t# size = filecxx . . $ kj/FileInputStream#file..statcxx . . $ kj/FsNode#stat(f1616eaa2c5044ee).().sizecxx . . $ kj/FsNode#Metadata#size.;
2784 return offsetcxx . . $ kj/Maybe#Maybe(fe7a8a4d1eddb70). < size ? size - offsetcxx . . $ kj/FileInputStream#offset. : 0;
2785 }
2786
2787 Promisecxx . . $ kj/Promise#<void> FileOutputStreamcxx . . $ kj/FileOutputStream#::writecxx . . $ kj/FileOutputStream#write(7ee344f2bd176b7a).(const void* buffer, size_t size) {
2788 filecxx . . $ kj/FileOutputStream#file..writecxx . . $ kj/File#write(ee8861e087ba2601).(offsetcxx . . $ kj/FileOutputStream#offset., arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(reinterpret_cast<const bytecxx . . $ kj/byte#*>(buffer), size));
2789 offsetcxx . . $ kj/FileOutputStream#offset. += size;
2790 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
2791 }
2792
2793 Promisecxx . . $ kj/Promise#<void> FileOutputStreamcxx . . $ kj/FileOutputStream#::writecxx . . $ kj/FileOutputStream#write(251ec43b44baa62).(ArrayPtrcxx . . $ kj/ArrayPtr#<const ArrayPtrcxx . . $ kj/ArrayPtr#<const bytecxx . . $ kj/byte#>> pieces) {
2794 // TODO(perf): Extend kj::File with an array-of-arrays write?
2795 for (auto piece: pieces) {
2796 filecxx . . $ kj/FileOutputStream#file..writecxx . . $ kj/File#write(ee8861e087ba2601).(offsetcxx . . $ kj/FileOutputStream#offset., piece);
2797 offsetcxx . . $ kj/FileOutputStream#offset. += piece.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).();
2798 }
2799 return kjcxx . . $ kj/::READY_NOWcxx . . $ kj/READY_NOW.;
2800 }
2801
2802 Promisecxx . . $ kj/Promise#<void> FileOutputStreamcxx . . $ kj/FileOutputStream#::whenWriteDisconnectedcxx . . $ kj/FileOutputStream#whenWriteDisconnected(542ddddf9229d39a).() {
2803 return kjcxx . . $ kj/::NEVER_DONEcxx . . $ kj/NEVER_DONE.;
2804 }
2805
2806 // =======================================================================================
2807
2808 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
2809
2810 class AggregateConnectionReceivercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver# final: public ConnectionReceivercxx . . $ kj/ConnectionReceiver# {
2811 public:
2812 AggregateConnectionReceivercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#AggregateConnectionReceiver(9ce7509b7167d9a6).(Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#>> receiversParam)
2813 : receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(receiversParam)),
2814 acceptTaskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptTasks.(kjcxx . . $ kj/::heapArraycxx . . $ kj/heapArray(30935e9a1d746cdf).<Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<void>>>(receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers..sizecxx . . $ kj/Array#size(fe4d2d262d4164a8).())) {}
2815
2816 Promisecxx . . $ kj/Promise#<Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#>> acceptcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#accept(61a533e69b34abe2).() override {
2817 return acceptAuthenticatedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptAuthenticated(f5454c7a382d7752).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#&& authenticated) {
2818 return kjcxx . . $ kj/Own#Own(2757233a295510d2).::mvcxx . . $ kj/mv(9768e8ef939d477).(authenticated.streamcxx . . $ kj/AuthenticatedStream#stream.);
2819 });
2820 }
2821
2822 Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#> acceptAuthenticatedcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptAuthenticated(f5454c7a382d7752).() override {
2823 // Whenever our accept() is called, we want it to resolve to the first connection accepted by
2824 // any of our child receivers. Naively, it may seem like we should call accept() on them all
2825 // and exclusiveJoin() the results. Unfortunately, this might not work in a certain race
2826 // condition: if two or more of our children receive connections simultaneously, both child
2827 // accept() calls may return, but we'll only end up taking one and dropping the other.
2828 //
2829 // To avoid this problem, we must instead initiate `accept()` calls on all children, and even
2830 // after one of them returns a result, we must allow the others to keep running. If we end up
2831 // accepting any sockets from children when there is no outstanding accept() on the aggregate,
2832 // we must put that socket into a backlog. We only restart accept() calls on children if the
2833 // backlog is empty, and hence the maximum length of the backlog is the number of children
2834 // minus 1.
2835
2836 if (backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog..emptycxx . . $ std/deque#empty(3482b152b9333168).()) {
2837 auto result = kjcxx . . $ kj/::newAdaptedPromisecxx . . $ kj/newAdaptedPromise(c7160b5aa0d63c40).<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#, Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#>(*this);
2838 ensureAllAcceptingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#ensureAllAccepting(49f6e7a06ebc5aa8).();
2839 return result;
2840 } else {
2841 auto result = kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).());
2842 backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog..pop_frontcxx . . $ std/deque#pop_front(ced63f7c635d850d).();
2843 return result;
2844 }
2845 }
2846
2847 uintcxx . . $ kj/uint# getPortcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#getPort(db52760e79bf9054).() override {
2848 return receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).0]->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).getPortcxx . . $ kj/ConnectionReceiver#getPort(db52760e79bf9054).();
2849 }
2850 void getsockoptcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#getsockopt(8f49a46285e37e42).(int level, int option, void* value, uintcxx . . $ kj/uint#* length) override {
2851 return receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).0]->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).getsockoptcxx . . $ kj/ConnectionReceiver#getsockopt(8f49a46285e37e42).(level, option, value, length);
2852 }
2853 void setsockoptcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#setsockopt(beb4e39792953a71).(int level, int option, const void* value, uintcxx . . $ kj/uint# length) override {
2854 // Apply to all.
2855 for (auto& r: receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.) {
2856 r->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).setsockoptcxx . . $ kj/ConnectionReceiver#setsockopt(beb4e39792953a71).(level, option, value, length);
2857 }
2858 }
2859 void getsocknamecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#getsockname(553581679dd6ad96).(struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint#* length) override {
2860 return receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).0]->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).getsocknamecxx . . $ kj/ConnectionReceiver#getsockname(553581679dd6ad96).(addr, length);
2861 }
2862
2863 private:
2864 Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#>> receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.;
2865 Arraycxx . . $ kj/Array#<Maybecxx . . $ kj/Maybe#<Promisecxx . . $ kj/Promise#<void>>> acceptTaskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptTasks.;
2866
2867 struct Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter# {
2868 Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#Waiter(3fe246cdf013cd63).(PromiseFulfillercxx . . $ kj/PromiseFulfiller#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#>& fulfiller,
2869 AggregateConnectionReceivercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#& parent)
2870 : fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#fulfiller.(fulfiller), parentcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#parent.(parent) {
2871 parent.waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..addcxx . . $ kj/List#add(8e935d9c2e576e3a).(*this);
2872 }
2873 ~cxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#`~Waiter`(49f6e7a06ebc5aa8).Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#() noexcept(false) {
2874 if (linkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#link..isLinkedcxx . . $ kj/ListLink#isLinked(50ce9a9e25b4a850).()) {
2875 parentcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#parent..waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..removecxx . . $ kj/List#remove(8e935d9c2e576e3a).(*this);
2876 }
2877 }
2878
2879 PromiseFulfillercxx . . $ kj/PromiseFulfiller#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#>& fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#fulfiller.;
2880 AggregateConnectionReceivercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#& parentcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#parent.;
2881 ListLinkcxx . . $ kj/ListLink#<Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#> linkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#link.;
2882 };
2883
2884 Listcxx . . $ kj/List#<Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#, &Waitercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#::linkcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#link.> waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters.;
2885 stdcxx . . $ std/::dequecxx . . $ std/deque#<Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#>> backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog.;
2886 // At least one of `waiters` or `backlog` is always empty.
2887
2888 void ensureAllAcceptingcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#ensureAllAccepting(49f6e7a06ebc5aa8).() {
2889 for (auto i: kjcxx . . $ kj/::indicescxx . . $ kj/indices(5511956b41a96918).(receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.)) {
2890 if (acceptTaskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptTasks.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).i] ==cxx . . $ kj/Maybe#`operator==`(b102b25da64d45e5). nullptr) {
2891 acceptTaskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptTasks.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).i] =cxx . . $ kj/Maybe#`operator=`(3b798851889fcb13). acceptLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptLoop(fbebfaec491a90).(i);
2892 }
2893 }
2894 }
2895
2896 Promisecxx . . $ kj/Promise#<void> acceptLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptLoop(fbebfaec491a90).(size_t index) {
2897 return kjcxx . . $ kj/::evalNowcxx . . $ kj/evalNow(2a9d78fa55ded97b).([&]() { return receiverscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#receivers.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).index]->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).acceptAuthenticatedcxx . . $ kj/ConnectionReceiver#acceptAuthenticated(f5454c7a382d7752).(); })
2898 .thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this](AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#&& as) {
2899 if (waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..emptycxx . . $ kj/List#empty(50ce9a9e25b4a850).()) {
2900 backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog..push_backcxx . . $ std/deque#push_back(fe7a8a4d1eddb70).(kjcxx . . $ kj/Promise#Promise(d2a2e67ecf6e02d9).::mvcxx . . $ kj/mv(9768e8ef939d477).(as));
2901 } else {
2902 auto& waiter = waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..frontcxx . . $ kj/List#front(19b2b6f17af048b).();
2903 waiter.fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#fulfiller..fulfillcxx . . $ kj/PromiseFulfiller#fulfill(fe7a8a4d1eddb70).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(as));
2904 waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..removecxx . . $ kj/List#remove(8e935d9c2e576e3a).(waiter);
2905 }
2906 }, [this](Exceptioncxx . . $ kj/Exception#&& e) {
2907 if (waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..emptycxx . . $ kj/List#empty(50ce9a9e25b4a850).()) {
2908 backlogcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#backlog..push_backcxx . . $ std/deque#push_back(fe7a8a4d1eddb70).(kjcxx . . $ kj/Promise#Promise(c33f37f983fdaa7c).::mvcxx . . $ kj/mv(9768e8ef939d477).(e));
2909 } else {
2910 auto& waiter = waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..frontcxx . . $ kj/List#front(19b2b6f17af048b).();
2911 waiter.fulfillercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#Waiter#fulfiller..rejectcxx . . $ kj/PromiseFulfiller#reject(c33f37f983fdaa7c).(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(e));
2912 waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..removecxx . . $ kj/List#remove(8e935d9c2e576e3a).(waiter);
2913 }
2914 }).thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([this, index]() -> Promisecxx . . $ kj/Promise#<void> {
2915 if (waiterscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#waiters..emptycxx . . $ kj/List#empty(50ce9a9e25b4a850).()) {
2916 // Don't keep accepting if there's no one waiting.
2917 // HACK: We can't cancel ourselves, so detach the task so we can null out the slot.
2918 // We know that the promise we're detaching here is exactly the promise that's currently
2919 // executing and has no further `.then()`s on it, so no further callbacks will run in
2920 // detached state... we're just using `detach()` as a tricky way to have the event loop
2921 // dispose of this promise later after we've returned.
2922 // TODO(cleanup): This pattern has come up several times, we need a better way to handle
2923 // it.
2924 KJ_ASSERT_NONNULLcxx . . $ `src/kj/debug.h:361:9`!(acceptTasks[index]).detachcxx . . $ kj/Promise#detach(4f6c0277e8680150).([](auto&&) {});
2925 acceptTaskscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptTasks.[cxx . . $ kj/Array#`operator[]`(ec43b8547ac5c60).index] =cxx . . $ kj/Maybe#`operator=`(915852c841c8eef9). nullptr;
2926 return READY_NOWcxx . . $ kj/READY_NOW.;
2927 } else {
2928 return acceptLoopcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#acceptLoop(fbebfaec491a90).(index);
2929 }
2930 });
2931 }
2932 };
2933
2934 } // namespace
2935
2936 Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#> newAggregateConnectionReceivercxx . . $ kj/newAggregateConnectionReceiver(6798675dcad27cbb).(Arraycxx . . $ kj/Array#<Owncxx . . $ kj/Own#<ConnectionReceivercxx . . $ kj/ConnectionReceiver#>> receivers) {
2937 return kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<AggregateConnectionReceivercxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/AggregateConnectionReceiver#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(receivers));
2938 }
2939
2940 // -----------------------------------------------------------------------------
2941
2942 namespace _cxx . . $ kj/_/ { // private
2943
2944 #if !_WIN32
2945
2946 kjcxx . . $ kj/::ArrayPtrcxx . . $ kj/ArrayPtr#<const char> safeUnixPathcxx . . $ kj/_/safeUnixPath(afd5b73af090a88b).(const struct sockaddr_uncxx . . $ sockaddr_un#* addr, uintcxx . . $ kj/uint# addrlen) {
2947 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(addr->sun_family == AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!, "not a unix address");
2948 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(addrlen >= offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:431:9`!(sockaddr_un, sun_path), "invalid unix address");
2949
2950 size_t maxPathlen = addrlen - offsetofcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:431:9`!(sockaddr_un, sun_path);
2951
2952 size_t pathlen;
2953 if (maxPathlen > 0 && addr->sun_pathcxx . . $ sockaddr_un#sun_path.[0] == '\0') {
2954 // Linux "abstract" unix address
2955 pathlen = strnlen(addr->sun_pathcxx . . $ sockaddr_un#sun_path. + 1, maxPathlen - 1) + 1;
2956 } else {
2957 pathlen = strnlen(addr->sun_pathcxx . . $ sockaddr_un#sun_path., maxPathlen);
2958 }
2959 return kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(addr->sun_pathcxx . . $ sockaddr_un#sun_path., pathlen);
2960 }
2961
2962 #endif // !_WIN32
2963
2964 ArrayPtrcxx . . $ kj/ArrayPtr#<const CidrRangecxx . . $ kj/CidrRange#> localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).() {
2965 static const CidrRangecxx . . $ kj/CidrRange# result[] = {
2966 // localhost
2967 "127.0.0.0/8"_kjcxx . . $ `operator""_kj`(f0c11caeac747).,
2968 "::1/128"_kjcxx . . $ `operator""_kj`(f0c11caeac747).,
2969
2970 // Trying to *connect* to 0.0.0.0 on many systems is equivalent to connecting to localhost.
2971 // (wat)
2972 "0.0.0.0/32"_kjcxx . . $ `operator""_kj`(f0c11caeac747).,
2973 "::/128"_kjcxx . . $ `operator""_kj`(f0c11caeac747).,
2974 };
2975
2976 // TODO(cleanup): A bug in GCC 4.8, fixed in 4.9, prevents result from implicitly
2977 // casting to our return type.
2978 return kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(result, kjcxx . . $ kj/::sizecxx . . $ kj/size(2ca297d61627c561).(result));
2979 }
2980
2981 ArrayPtrcxx . . $ kj/ArrayPtr#<const CidrRangecxx . . $ kj/CidrRange#> privateCidrscxx . . $ kj/_/privateCidrs(3391a496a67d201).() {
2982 static const CidrRangecxx . . $ kj/CidrRange# result[] = {
2983 "10.0.0.0/8"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC1918 reserved for internal network
2984 "100.64.0.0/10"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC6598 "shared address space" for carrier-grade NAT
2985 "169.254.0.0/16"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC3927 "link local" (auto-configured LAN in absence of DHCP)
2986 "172.16.0.0/12"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC1918 reserved for internal network
2987 "192.168.0.0/16"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC1918 reserved for internal network
2988
2989 "fc00::/7"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC4193 unique private network
2990 "fe80::/10"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC4291 "link local" (auto-configured LAN in absence of DHCP)
2991 };
2992
2993 // TODO(cleanup): A bug in GCC 4.8, fixed in 4.9, prevents result from implicitly
2994 // casting to our return type.
2995 return kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(result, kjcxx . . $ kj/::sizecxx . . $ kj/size(2ca297d61627c561).(result));
2996 }
2997
2998 ArrayPtrcxx . . $ kj/ArrayPtr#<const CidrRangecxx . . $ kj/CidrRange#> reservedCidrscxx . . $ kj/_/reservedCidrs(3391a496a67d201).() {
2999 static const CidrRangecxx . . $ kj/CidrRange# result[] = {
3000 "192.0.0.0/24"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC6890 reserved for special protocols
3001 "224.0.0.0/4"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC1112 multicast
3002 "240.0.0.0/4"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC1112 multicast / reserved for future use
3003 "255.255.255.255/32"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC0919 broadcast address
3004
3005 "2001::/23"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC2928 reserved for special protocols
3006 "ff00::/8"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC4291 multicast
3007 };
3008
3009 // TODO(cleanup): A bug in GCC 4.8, fixed in 4.9, prevents result from implicitly
3010 // casting to our return type.
3011 return kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(result, kjcxx . . $ kj/::sizecxx . . $ kj/size(2ca297d61627c561).(result));
3012 }
3013
3014 ArrayPtrcxx . . $ kj/ArrayPtr#<const CidrRangecxx . . $ kj/CidrRange#> exampleAddressescxx . . $ kj/_/exampleAddresses(3391a496a67d201).() {
3015 static const CidrRangecxx . . $ kj/CidrRange# result[] = {
3016 "192.0.2.0/24"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC5737 "example address" block 1 -- like example.com for IPs
3017 "198.51.100.0/24"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC5737 "example address" block 2 -- like example.com for IPs
3018 "203.0.113.0/24"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC5737 "example address" block 3 -- like example.com for IPs
3019 "2001:db8::/32"_kjcxx . . $ `operator""_kj`(f0c11caeac747)., // RFC3849 "example address" block -- like example.com for IPs
3020 };
3021
3022 // TODO(cleanup): A bug in GCC 4.8, fixed in 4.9, prevents result from implicitly
3023 // casting to our return type.
3024 return kjcxx . . $ kj/::arrayPtrcxx . . $ kj/arrayPtr(e55e65d9587a059a).(result, kjcxx . . $ kj/::sizecxx . . $ kj/size(2ca297d61627c561).(result));
3025 }
3026
3027 bool matchesAnycxx . . $ kj/_/matchesAny(d80c9f06d81a040a).(ArrayPtrcxx . . $ kj/ArrayPtr#<const CidrRangecxx . . $ kj/CidrRange#> cidrs, const struct sockaddrcxx . . $ sockaddr#* addr) {
3028 for (auto& cidr: cidrs) {
3029 if (cidr.matchescxx . . $ kj/CidrRange#matches(8509e833ecc26564).(addr)) return true;
3030 }
3031 return false;
3032 }
3033
3034 NetworkFiltercxx . . $ kj/_/NetworkFilter#::NetworkFiltercxx . . $ kj/_/NetworkFilter#NetworkFilter(49f6e7a06ebc5aa8).()
3035 : allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix.(true), allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix.(true) {
3036 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addcxx . . $ kj/Vector#add(7f9966f43a57f391).(CidrRangecxx . . $ kj/CidrRange#::inet4cxx . . $ kj/CidrRange#inet4(c660ce3fdab1ec19).({cxx . . $ kj/ArrayPtr#ArrayPtr(e8dc38cd28254f6b).0,0,0,0}, 0));
3037 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addcxx . . $ kj/Vector#add(7f9966f43a57f391).(CidrRangecxx . . $ kj/CidrRange#::inet6cxx . . $ kj/CidrRange#inet6(3f42a27210ebbac1).({cxx . . $ kj/ArrayPtr#ArrayPtr(49f6e7a06ebc5aa8).}, {cxx . . $ kj/ArrayPtr#ArrayPtr(49f6e7a06ebc5aa8).}, 0));
3038 denyCidrscxx . . $ kj/_/NetworkFilter#denyCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(reservedCidrscxx . . $ kj/_/reservedCidrs(3391a496a67d201).());
3039 }
3040
3041 NetworkFiltercxx . . $ kj/_/NetworkFilter#::NetworkFiltercxx . . $ kj/_/NetworkFilter#NetworkFilter(4a04c564a63ba9bb).(ArrayPtrcxx . . $ kj/ArrayPtr#<const StringPtrcxx . . $ kj/StringPtr#> allow, ArrayPtrcxx . . $ kj/ArrayPtr#<const StringPtrcxx . . $ kj/StringPtr#> deny,
3042 NetworkFiltercxx . . $ kj/_/NetworkFilter#& next)
3043 : allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix.(false), allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix.(false), nextcxx . . $ kj/_/NetworkFilter#next.(next) {
3044 for (auto rule: allow) {
3045 if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "local"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3046 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).());
3047 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "network"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3048 // Can't be represented as a simple union of CIDRs, so we handle in shouldAllow().
3049 allowNetworkcxx . . $ kj/_/NetworkFilter#allowNetwork. = true;
3050 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "private"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3051 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(privateCidrscxx . . $ kj/_/privateCidrs(3391a496a67d201).());
3052 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).());
3053 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "public"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3054 // Can't be represented as a simple union of CIDRs, so we handle in shouldAllow().
3055 allowPubliccxx . . $ kj/_/NetworkFilter#allowPublic. = true;
3056 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "unix"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3057 allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix. = true;
3058 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "unix-abstract"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3059 allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix. = true;
3060 } else {
3061 allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs..addcxx . . $ kj/Vector#add(7f9966f43a57f391).(CidrRangecxx . . $ kj/CidrRange#(rule));
3062 }
3063 }
3064
3065 for (auto rule: deny) {
3066 if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "local"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3067 denyCidrscxx . . $ kj/_/NetworkFilter#denyCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).());
3068 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "network"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3069 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("don't deny 'network', allow 'local' instead");
3070 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "private"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3071 denyCidrscxx . . $ kj/_/NetworkFilter#denyCidrs..addAllcxx . . $ kj/Vector#addAll(4f6c0277e8680150).(privateCidrscxx . . $ kj/_/privateCidrs(3391a496a67d201).());
3072 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "public"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3073 // Tricky: What if we allow 'network' and deny 'public'?
3074 KJ_FAIL_REQUIREcxx . . $ `src/kj/debug.h:232:9`!("don't deny 'public', allow 'private' instead");
3075 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "unix"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3076 allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix. = false;
3077 } else if (rule ==cxx . . $ kj/StringPtr#`operator==`(92cba9538efd7e94). "unix-abstract"cxx . . $ kj/StringPtr#StringPtr(85c52e162fed56f9).) {
3078 allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix. = false;
3079 } else {
3080 denyCidrscxx . . $ kj/_/NetworkFilter#denyCidrs..addcxx . . $ kj/Vector#add(7f9966f43a57f391).(CidrRangecxx . . $ kj/CidrRange#(rule));
3081 }
3082 }
3083 }
3084
3085 bool NetworkFiltercxx . . $ kj/_/NetworkFilter#::shouldAllowcxx . . $ kj/_/NetworkFilter#shouldAllow(76befadadad58264).(const struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint# addrlen) {
3086 KJ_REQUIREcxx . . $ `src/kj/debug.h:227:9`!(addrlen >= sizeof(addr->sa_family));
3087
3088 #if !_WIN32
3089 if (addr->sa_familycxx . . $ sockaddr#sa_family. == AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!) {
3090 auto path = safeUnixPathcxx . . $ kj/_/safeUnixPath(afd5b73af090a88b).(reinterpret_cast<const struct sockaddr_uncxx . . $ sockaddr_un#*>(addr), addrlen);
3091 if (path.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && path[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0] == '\0') {
3092 return allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix.;
3093 } else {
3094 return allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix.;
3095 }
3096 }
3097 #endif
3098
3099 bool allowed = false;
3100 uintcxx . . $ kj/uint# allowSpecificity = 0;
3101
3102 if (allowPubliccxx . . $ kj/_/NetworkFilter#allowPublic.) {
3103 if ((addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`! || addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!) &&
3104 !matchesAnycxx . . $ kj/_/matchesAny(d80c9f06d81a040a).(privateCidrscxx . . $ kj/_/privateCidrs(3391a496a67d201).(), addr) && !matchesAnycxx . . $ kj/_/matchesAny(d80c9f06d81a040a).(localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).(), addr)) {
3105 allowed = true;
3106 // Don't adjust allowSpecificity as this match has an effective specificity of zero.
3107 }
3108 }
3109
3110 if (allowNetworkcxx . . $ kj/_/NetworkFilter#allowNetwork.) {
3111 if ((addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`! || addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!) &&
3112 !matchesAnycxx . . $ kj/_/matchesAny(d80c9f06d81a040a).(localCidrscxx . . $ kj/_/localCidrs(3391a496a67d201).(), addr)) {
3113 allowed = true;
3114 // Don't adjust allowSpecificity as this match has an effective specificity of zero.
3115 }
3116 }
3117
3118 for (auto& cidr: allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs.) {
3119 if (cidr.matchescxx . . $ kj/CidrRange#matches(8509e833ecc26564).(addr)) {
3120 allowSpecificity = kjcxx . . $ kj/::maxcxx . . $ kj/max(4af833f8d939a8d2).(allowSpecificity, cidr.getSpecificitycxx . . $ kj/CidrRange#getSpecificity(ddd8539a2fcdd4ce).());
3121 allowed = true;
3122 }
3123 }
3124 if (!allowed) return false;
3125 for (auto& cidr: denyCidrscxx . . $ kj/_/NetworkFilter#denyCidrs.) {
3126 if (cidr.matchescxx . . $ kj/CidrRange#matches(8509e833ecc26564).(addr)) {
3127 if (cidr.getSpecificitycxx . . $ kj/CidrRange#getSpecificity(ddd8539a2fcdd4ce).() >= allowSpecificity) return false;
3128 }
3129 }
3130
3131 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(n, next) {
3132 return n->shouldAllowcxx . . $ kj/_/NetworkFilter#shouldAllow(76befadadad58264).(addr, addrlen);
3133 } else {
3134 return true;
3135 }
3136 }
3137
3138 bool NetworkFiltercxx . . $ kj/_/NetworkFilter#::shouldAllowParsecxx . . $ kj/_/NetworkFilter#shouldAllowParse(76befadadad58264).(const struct sockaddrcxx . . $ sockaddr#* addr, uintcxx . . $ kj/uint# addrlen) {
3139 bool matched = false;
3140 #if !_WIN32
3141 if (addr->sa_familycxx . . $ sockaddr#sa_family. == AF_UNIXcxx . . $ `<external>/8962547315054503424/socket.h:95:9`!) {
3142 auto path = safeUnixPathcxx . . $ kj/_/safeUnixPath(afd5b73af090a88b).(reinterpret_cast<const struct sockaddr_uncxx . . $ sockaddr_un#*>(addr), addrlen);
3143 if (path.sizecxx . . $ kj/ArrayPtr#size(fe4d2d262d4164a8).() > 0 && path[cxx . . $ kj/ArrayPtr#`operator[]`(ec43b8547ac5c60).0] == '\0') {
3144 if (allowAbstractUnixcxx . . $ kj/_/NetworkFilter#allowAbstractUnix.) matched = true;
3145 } else {
3146 if (allowUnixcxx . . $ kj/_/NetworkFilter#allowUnix.) matched = true;
3147 }
3148 } else {
3149 #endif
3150 if ((addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`! || addr->sa_familycxx . . $ sockaddr#sa_family. == AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!) &&
3151 (allowPubliccxx . . $ kj/_/NetworkFilter#allowPublic. || allowNetworkcxx . . $ kj/_/NetworkFilter#allowNetwork.)) {
3152 matched = true;
3153 }
3154 for (auto& cidr: allowCidrscxx . . $ kj/_/NetworkFilter#allowCidrs.) {
3155 if (cidr.matchesFamilycxx . . $ kj/CidrRange#matchesFamily(4a668f6de69bf818).(addr->sa_familycxx . . $ sockaddr#sa_family.)) {
3156 matched = true;
3157 }
3158 }
3159 #if !_WIN32
3160 }
3161 #endif
3162
3163 if (matched) {
3164 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(n, next) {
3165 return n->shouldAllowParsecxx . . $ kj/_/NetworkFilter#shouldAllowParse(76befadadad58264).(addr, addrlen);
3166 } else {
3167 return true;
3168 }
3169 } else {
3170 // No allow rule matches this address family, so don't even allow parsing it.
3171 return false;
3172 }
3173 }
3174
3175 } // namespace _ (private)
3176
3177 // =======================================================================================
3178 // PeerIdentity implementations
3179
3180 namespacecxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/ {
3181
3182 class NetworkPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl# final: public NetworkPeerIdentitycxx . . $ kj/NetworkPeerIdentity# {
3183 public:
3184 NetworkPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#NetworkPeerIdentityImpl(21f41f80003bc3c2).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<NetworkAddresscxx . . $ kj/NetworkAddress#> addr): addrcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#addr.(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(addr)) {}
3185
3186 kjcxx . . $ kj/::Stringcxx . . $ kj/String# toStringcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#toString(af22d04b00c82e5d).() override { return addrcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#addr.->cxx . . $ kj/Own#`operator->`(155dc7f103cdb9db).toStringcxx . . $ kj/NetworkAddress#toString(af22d04b00c82e5d).(); }
3187 NetworkAddresscxx . . $ kj/NetworkAddress#& getAddresscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#getAddress(174cf8638fc59fcd).() override { return *cxx . . $ kj/Own#`operator*`(ed53f71ddbc8dcc3).addrcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#addr.; }
3188
3189 private:
3190 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<NetworkAddresscxx . . $ kj/NetworkAddress#> addrcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#addr.;
3191 };
3192
3193 class LocalPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl# final: public LocalPeerIdentitycxx . . $ kj/LocalPeerIdentity# {
3194 public:
3195 LocalPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#LocalPeerIdentityImpl(6a282afcd471a0cf).(Credentialscxx . . $ kj/LocalPeerIdentity#Credentials# creds): credscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#creds.(creds) {}
3196
3197 kjcxx . . $ kj/::Stringcxx . . $ kj/String# toStringcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#toString(af22d04b00c82e5d).() override {
3198 char pidBuffer[16];
3199 kjcxx . . $ kj/::StringPtrcxx . . $ kj/StringPtr# pidStr = nullptrcxx . . $ kj/StringPtr#StringPtr(49b4c06ce5d54a60).;
3200 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(p, creds.pid) {
3201 pidStr =cxx . . $ kj/StringPtr#`operator=`(4ab5fe27de865d02). strPreallocatedcxx . . $ kj/strPreallocated(e565017583c99bb4).(pidBuffercxx . . $ kj/ArrayPtr#ArrayPtr(37a1ddb7d9d83419)., " pid:", *p);
3202 }
3203
3204 char uidBuffer[16];
3205 kjcxx . . $ kj/::StringPtrcxx . . $ kj/StringPtr# uidStr = nullptrcxx . . $ kj/StringPtr#StringPtr(49b4c06ce5d54a60).;
3206 KJ_IF_MAYBEcxx . . $ `src/kj/common.h:1325:9`!(u, creds.uid) {
3207 uidStr =cxx . . $ kj/StringPtr#`operator=`(4ab5fe27de865d02). strPreallocatedcxx . . $ kj/strPreallocated(e565017583c99bb4).(uidBuffercxx . . $ kj/ArrayPtr#ArrayPtr(37a1ddb7d9d83419)., " uid:", *u);
3208 }
3209
3210 return kjcxx . . $ kj/::strcxx . . $ kj/str(d4f75be60228bbc5).("(local peer", pidStr, uidStr, ")");
3211 }
3212
3213 Credentialscxx . . $ kj/LocalPeerIdentity#Credentials# getCredentialscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#getCredentials(c4e30f98af5d767f).() override { return credscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#creds.; }
3214
3215 private:
3216 Credentialscxx . . $ kj/LocalPeerIdentity#Credentials# credscxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#creds.;
3217 };
3218
3219 class UnknownPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/UnknownPeerIdentityImpl# final: public UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity# {
3220 public:
3221 kjcxx . . $ kj/::Stringcxx . . $ kj/String# toStringcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/UnknownPeerIdentityImpl#toString(af22d04b00c82e5d).() override {
3222 return kjcxx . . $ kj/::strcxx . . $ kj/str(d4f75be60228bbc5).("(unknown peer)");
3223 }
3224 };
3225
3226 } // namespace
3227
3228 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<NetworkPeerIdentitycxx . . $ kj/NetworkPeerIdentity#> NetworkPeerIdentitycxx . . $ kj/NetworkPeerIdentity#::newInstancecxx . . $ kj/NetworkPeerIdentity#newInstance(e93985e5a886d145).(kjcxx . . $ kj/::Owncxx . . $ kj/Own#<NetworkAddresscxx . . $ kj/NetworkAddress#> addr) {
3229 return kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<NetworkPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/NetworkPeerIdentityImpl#>(kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(addr));
3230 }
3231
3232 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<LocalPeerIdentitycxx . . $ kj/LocalPeerIdentity#> LocalPeerIdentitycxx . . $ kj/LocalPeerIdentity#::newInstancecxx . . $ kj/LocalPeerIdentity#newInstance(59755aacbc2abbba).(LocalPeerIdentitycxx . . $ kj/LocalPeerIdentity#::Credentialscxx . . $ kj/LocalPeerIdentity#Credentials# creds) {
3233 return kjcxx . . $ kj/Own#Own(97d08cb47632509f).::heapcxx . . $ kj/heap(bae2fec6325dc41a).<LocalPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/LocalPeerIdentityImpl#>(creds);
3234 }
3235
3236 kjcxx . . $ kj/::Owncxx . . $ kj/Own#<UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#> UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#::newInstancecxx . . $ kj/UnknownPeerIdentity#newInstance(652c5475fc6e4300).() {
3237 static UnknownPeerIdentityImplcxx . . $ kj/`$anonymous_namespace_src/kj/async-io.c++`/UnknownPeerIdentityImpl# instance;
3238 return {cxx . . $ kj/Own#Own(3121d07a91835495). &instance, NullDisposercxx . . $ kj/NullDisposer#::instancecxx . . $ kj/NullDisposer#instance. };
3239 }
3240
3241 Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#> ConnectionReceivercxx . . $ kj/ConnectionReceiver#::acceptAuthenticatedcxx . . $ kj/ConnectionReceiver#acceptAuthenticated(f5454c7a382d7752).() {
3242 return acceptcxx . . $ kj/ConnectionReceiver#accept(61a533e69b34abe2).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> stream) {
3243 return AuthenticatedStreamcxx . . $ kj/AuthenticatedStream# { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(stream), UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#::newInstancecxx . . $ kj/UnknownPeerIdentity#newInstance(652c5475fc6e4300).() };
3244 });
3245 }
3246
3247 Promisecxx . . $ kj/Promise#<AuthenticatedStreamcxx . . $ kj/AuthenticatedStream#> NetworkAddresscxx . . $ kj/NetworkAddress#::connectAuthenticatedcxx . . $ kj/NetworkAddress#connectAuthenticated(f5454c7a382d7752).() {
3248 return connectcxx . . $ kj/NetworkAddress#connect(61a533e69b34abe2).().thencxx . . $ kj/Promise#then(fd6a6beaa0df29f).([](Owncxx . . $ kj/Own#<AsyncIoStreamcxx . . $ kj/AsyncIoStream#> stream) {
3249 return AuthenticatedStreamcxx . . $ kj/AuthenticatedStream# { kjcxx . . $ kj/::mvcxx . . $ kj/mv(9768e8ef939d477).(stream), UnknownPeerIdentitycxx . . $ kj/UnknownPeerIdentity#::newInstancecxx . . $ kj/UnknownPeerIdentity#newInstance(652c5475fc6e4300).() };
3250 });
3251 }
3252
3253 } // namespace kj