[Brainstorm] May std::iostream adapt with stdexec ? #1513
anonymouspc
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is only a brainstorm. This paragraph talks about the possibility instead of the implemention-detail of it
Idea
As is known to all,
<iostream>
is a successful and widely-used abstraction of sync-io.I'm thinking a kind of
async_iostream
, which provides interfaces like this (let's begin with an example likestd::fstream
):Meanwhile all algorithms on synchronous std::iostream is keeped, for example:
The "operator<<" overload exactly in same way as synchronous std::iostream, like this:
std::ostream
(sync) itself is a sender (maybe template-specialized?),sync_wait
it has not effect.std::this_thread::sync_wait(ofstream << "Hello")
has same effect as the one withoutsync_wait
,std::this_thread::sync_wait(async_ofstream << "Hello")
actually returns a lazy sender (which works likestd::this_thread::sync_wait(boost::asio::socket().async_send("Hello", use_sender))
).Maybe we can add some algorithms like this:
Pros
It only make
cout
to something async, which does not break any grammar or expression. Everyone can easily get started to async-io, without learning anything more than their first class of C++. It is simple.Cons
The possible ways are:
std::execution
, okay westd::execution::just
these values. But most times wejust(std::move(values...))
, and herehuge_eigen_matrix
might be inproper (?),huge_eigen_matrix
(likestd::cout << std::move(matrix)
) does not keep grammar same as sync-iostrema.Boost.Asio
, oh we only acceptboost::asio::buffer
(something similar tostd::span
), i asio dont care about the lifetime.Beta Was this translation helpful? Give feedback.
All reactions