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

异步io是通过多线程进行模拟的吗 #31

Open
jujujuxb opened this issue Aug 1, 2022 · 1 comment
Open

异步io是通过多线程进行模拟的吗 #31

jujujuxb opened this issue Aug 1, 2022 · 1 comment

Comments

@jujujuxb
Copy link

jujujuxb commented Aug 1, 2022

No description provided.

@Gooddbird
Copy link
Owner

你好,请问你这里的异步io更具体一点指的是哪里。如果是说异步的 read、write 的话, 实际上这块是通过协程的自动切换配合 reactor 调度协程池来实现的。 基于此实际上无需多线程,即使是单个线程也能达到异步 IO 的效果。read 的时候让出当前协程,转而去执行其他的代码,当 可读条件就绪后线程再 唤醒这个协程,此时满足可读条件,直接进行read即可。这个过程即使是只有一个线程也能满足,当然多个线程也没问题。

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

No branches or pull requests

2 participants