Skip to content
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

修正嵌套的 asio 协程内部启动的 ucoro 协程无法再调用 asio 协程的错误 #18

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

microcai
Copy link
Member

ucoro 协程能调用 asio 协程的关键是, local_storage 绑定了一个 io_context 但是,在 asio 协程里,再次等待 ucoro 协程的时候,此时的 ucoro 协程却失去了 io_context

因此,这个嵌套在里面的 ucoro 就无法再调用 asio 的协程了。

解决的办法是把 executor 作为参数继续传下去,在 initiate_do_invoke_ucoro_awaitable 里面调用 ucoro 的 detach() 方法时,把 executor 传进去。

ucoro 协程能调用 asio 协程的关键是, local_storage 绑定了一个 io_context
但是,在 asio 协程里,再次等待 ucoro 协程的时候,此时的 ucoro 协程却失去了 io_context

因此,这个嵌套在里面的 ucoro 就无法再调用 asio 的协程了。

解决的办法是把 executor 作为参数继续传下去,在 initiate_do_invoke_ucoro_awaitable
里面调用 ucoro 的 detach() 方法时,把 executor 传进去。
@microcai microcai requested a review from Jackarain October 14, 2024 12:22
@Jackarain Jackarain merged commit 3f107d2 into master Oct 14, 2024
6 checks passed
@Jackarain Jackarain deleted the fix_asio_coro_chain_call branch October 14, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants