-
Notifications
You must be signed in to change notification settings - Fork 5
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
支持等待 .detach() 创建的协程 #26
Conversation
8a9f6e1
to
50a5d1c
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.
请简述实现原理
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.
就是给 awaitable_detached 添加 await_suspend 和 await_resume , 这样它就能被 co_await 了。
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.
主要是很多代码风格问题,还有一些功能上的问题:
1,co_await 的情况下,也需要考虑返回值。
2,同样也需要考虑异常转发。
OK. 等我发第二版 |
c1f35be
to
d3238bf
Compare
当调用 .detach(), 然后不等待它,那么这个 detch 的协程就直接后台跑了。就好像 create_thread 创建了个新线程一样。 当调用 .detach(), 然后使用 co_await 等待它,那么当前协程就等待这个 detach 的协程完成。 就好像调用 std.thread.join() 那样。
d3238bf
to
c4fac25
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
只有 test 命名稍需改善,其它一切看起来都没问题了。
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.
先 Approve,后面再统一修改 tests 的命名问题
当调用 .detach(), 然后不等待它,那么这个 detch 的协程就直接后台跑了。就好像 create_thread
创建了个新线程一样。
当调用 .detach(), 然后使用 co_await 等待它,那么当前协程就等待这个 detach 的协程完成。
就好像调用 std.thread.join() 那样。