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

reactor相关请教 #2

Closed
curtiseng opened this issue Jul 30, 2021 · 1 comment
Closed

reactor相关请教 #2

curtiseng opened this issue Jul 30, 2021 · 1 comment

Comments

@curtiseng
Copy link

curtiseng commented Jul 30, 2021

另一个是,多个 worker 线程会并发地执行 tasks,但只有一个 worker 线程会作为 reactor 来 poll events,新的 events 可能是由 reactor 自己,也可能是由其他 worker 线程来执行对应的 future。

文中这样描述,是否和 tokio-rs/tokio#660 这个pr冲突。

@tony612
Copy link
Owner

tony612 commented Aug 19, 2021

后来在这个 PR 改了一下,现在之后一个 reactor 了。可以看这里

当我们有多个 worker threads 时,只有一个 worker 会抢到 runtime::driver::Driver 的“锁”(没抢到的并不会挂起而是返回 None 而执行 else)而执行 park_driver,其他 worker 会 park_condvar,后边会看到 park_driver 其实就是 poll events,因此只有一个 worker 线程会成为 reactor

@tony612 tony612 closed this as completed Aug 19, 2021
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