-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Generator #279
feat: Add Generator #279
Conversation
2bf2cbb
to
987530b
Compare
因为 Generator 已经进入 C++标准了:https://github.com/cplusplus/papers/issues/1151 具体做法可以参考 asio::string 的实现,比如说:
感兴趣的话可以看看 folly 里的 AsyncGenerator,那个相对来说和异步的场景更贴合些。 |
好,我试试 |
Hmm, 差个递归和Allocator |
相比于 |
我还没细看,主要哪里不同? std generator 其实比起协程库更贴近于 Range 库,为了和 Range 的互操作性折腾了很多。虽然搞一个和 std generator 语义不同的 generator 也不是不行,但感觉有点奇怪。我的想法是 generator 的设计和实现都尽量把标准的搬过来就行,之后在 AsyncGenerator 里再做其他的事情。 因为本质上 generator (一般认为)是个同步组件,async_simple 更多是希望提供一些方便的异步组件,所以这里是有些差别的。 |
我看cppref 里 generator 里有一个 struct _Nest_info {
exception_ptr _Except;
coroutine_handle<_Gen_promise_base> _Parent;
coroutine_handle<_Gen_promise_base> _Root;
}; 这两个目的应该都是为了优化Generator的递归, 实现应该不太同, 我还没细看, 我再看看 嗯好的 我之后再去看看 |
e9ec31a
to
caa5568
Compare
可以自己hack一个
|
文档我慢慢加吧,可能会写得很慢 |
这个没有关系,那现在这个 PR 就不要求文档了。文档我也可以补下。 |
OK 好的 Lazy需要Allocator支持吗, 这个Allocator可以共享的, 我打算把 |
暂时先不用吧,加接口的事可以谨慎些。Coroutine 的语言设计里 Allocator 的位置挺奇怪,就挺不好用的,可以先放放。 |
恩好 |
@@ -103,6 +103,7 @@ else() | |||
-std=c++20 | |||
-D_GLIBCXX_USE_CXX11_ABI=1 | |||
-Wno-deprecated-register | |||
-Wno-mismatched-new-delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个对应的是什么warning 呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 warning 在哪里出现的呢,看着不太对
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 Wno 选项可以消掉吗?我感觉剩下的主要问题就是这个了
206546f
to
d0fec40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Why
#103
TODO:
add documents
What is changing
Example