- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.8k
macros: run new_current_thread() inside LocalSet #4147
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
Conversation
Allows using tokio::task::spawn_local() without further setup. Reapplies 33f0a1f, reverted for making tokio::task::block_in_place() panic with the multi-threaded variant of #[tokio::test]. This commit creates the LocalSet only for the single-threaded runtime. Still a significant Quality-of-Life improvement, IMO.
| Feedback, por favor? | 
| I haven't forgotten you, but I only look at non-simple things once a week, and I didn't get around to this PR this week. | 
| Quick recap: 33f0a1f was reverted because the newly introduced LocalSet interacts badly with block_in_place(). tokio/tokio/src/runtime/thread_pool/worker.rs Lines 284 to 286 in d047584 
 | 
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.
I've tested it with #[tokio::main] locally, and that works as well. We should get a couple more reviewers on this though; I am not familiar enough with some of the implementation details for localset to know if this leads to any changes in performance, and others may have opinions on this.
| One of the concerns we had with the original PR is that it gives  | 
| 
 We could disable spawn_local in  | 
| Right, having a  | 
| I'm retracting this. It turned out to be (a lot) quicker to just make appropriate changes to our code base than trying to upstream this change. | 
Allows using tokio::task::spawn_local() without further setup.
Reapplies 33f0a1f, reverted for making tokio::task::block_in_place()
panic with the multi-threaded variant of #[tokio::test].
This commit creates the LocalSet only for the single-threaded runtime.
Still a significant Quality-of-Life improvement, IMO.
edit: refs #4142