-
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
解决老中医提出的不能 syncAwait 然后捕获异常的问题。测试用例见 test7 #43
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
microcai
force-pushed
the
syncAwait-with-try-catch
branch
2 times, most recently
from
October 21, 2024 00:15
ebffbd4
to
6eed51d
Compare
EvinceMoi
reviewed
Oct 21, 2024
Jackarain
reviewed
Oct 21, 2024
Jackarain
reviewed
Oct 21, 2024
microcai
force-pushed
the
syncAwait-with-try-catch
branch
2 times, most recently
from
October 21, 2024 11:30
baaf174
to
edec9d4
Compare
microcai
force-pushed
the
syncAwait-with-try-catch
branch
2 times, most recently
from
October 21, 2024 13:12
9c97d76
to
b599c70
Compare
Jackarain
reviewed
Oct 21, 2024
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.
添加的 sync_await
看起来没什么大的问题了。
但是虽添加了 sync_await
且解决了异常传播的问题,而 coro_start
对于异常传播的问题,并未作修复。
microcai
force-pushed
the
syncAwait-with-try-catch
branch
from
October 21, 2024 15:43
b599c70
to
37ab113
Compare
简单的来说,就是 ```c++ try { start_coro(some_coro_that_throw()); } catch(...) { 这里抓不到异常 } ``` 原因是 start_coro 实际上同 asio 的 co_spawn 一样,分叉了。 这样就没办法抓异常了,除非修改some_coro_that_throw()本身的代码。 如果是 ```c++ co_await start_coro(some_coro_that_throw()); ``` 固然这样写,就抓的到异常了。但是在非协程上下文里,就无法使用了。 因此需要一种在非协程上下文环境里,同步等待协程的方式,并且能抓到异常。 所以这个补丁就是新增了一个 sync_await() 函数。具体使用就是 ```c++ void 常规函数() { try { sync_await(some_coro_that_throw()); } catch(...) { 这里能抓到异常 } } ```
microcai
force-pushed
the
syncAwait-with-try-catch
branch
from
October 21, 2024 15:49
37ab113
to
0dca587
Compare
修改好了 |
Jackarain
approved these changes
Oct 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
先提交下。有问题了留言。