File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed
Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change 1010#include < aws/io/async_stream.h>
1111#include < aws/io/stream.h>
1212
13- #include < future >
13+ #include < functional >
1414
1515namespace Aws
1616{
@@ -226,9 +226,9 @@ namespace Aws
226226
227227 /* *
228228 * Asynchronously read into buffer.
229- * @return future<bool> - true on success (including EOF/no data available ), false on error
229+ * Call onComplete( true) on success (including EOF), or onComplete( false) on error.
230230 */
231- virtual std::future< bool > ReadImpl (ByteBuf &buffer) noexcept = 0;
231+ virtual void ReadImpl (ByteBuf &buffer, std::function< void ( bool )> onComplete ) noexcept = 0;
232232
233233 private:
234234 static void s_Destroy (aws_async_input_stream *stream);
Original file line number Diff line number Diff line change 66#include < aws/crt/StlAllocator.h>
77#include < aws/crt/io/Stream.h>
88#include < iostream>
9- #include < thread>
109
1110#include < aws/io/future.h>
1211#include < aws/io/stream.h>
@@ -250,17 +249,11 @@ namespace Aws
250249 auto impl = static_cast <AsyncInputStream *>(stream->impl );
251250 auto future = aws_future_bool_new (impl->m_allocator );
252251
253- std::shared_future<bool > cppFuture = impl->ReadImpl (*dest).share ();
254-
255252 aws_future_bool_acquire (future);
256- std::thread (
257- [future, cppFuture]()
258- {
259- bool result = cppFuture.get ();
260- aws_future_bool_set_result (future, result);
261- aws_future_bool_release (future);
262- })
263- .detach ();
253+ impl->ReadImpl (*dest, [future](bool result) {
254+ aws_future_bool_set_result (future, result);
255+ aws_future_bool_release (future);
256+ });
264257
265258 return future;
266259 }
You can’t perform that action at this time.
0 commit comments