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.
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
linux: Feature gate async runtime, allowing opting between Tokio or smol #27
linux: Feature gate async runtime, allowing opting between Tokio or smol #27
Changes from 4 commits
824b0ad
82e2cc9
acf95c3
4818613
d597938
bd399c2
ba8e1d4
66218b6
9e7146e
ba8cd7a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Spawning a non-async function is a bit odd. Can we make it
async
?I think this will block the executor thread otherwise.
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.
interesting, why do you say this?
btw was able to test on a mac and confirm
background_task
'sCFRunLoop::run_current()
seems to run forever, and pertokio
spawn_blocking
doc for example:so we should probably maintain the plain old
std::thread::spawn
, wdyt?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.
Unless interrupted otherwise, a task will run on an executor thread until it yields, i.e. returns
Poll::Pending
.async_std has a mechanism to detect blocked executor threads and spawn new ones: https://async.rs/blog/stop-worrying-about-blocking-the-new-async-std-runtime/
Tokio doesn't though and it is a conscious design decision AFAIK.
But you are not using
spawn_blocking
right? So how is that relevant?Can we refactor this to be similar to the linux implementation where we register a waker and call it in a callback?
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.
Right yeah, but a function just by not being
async
doesn't mean it will block the thread.because
background_task
'sCFRunLoop::run_current()
seems to run forever, therefore blocking the thread.Yeah I think so, but there still still need for a blocking thread as
CFRunLoop::run_current()
is blocking, while the WindowsNotifyIpInterfaceChange
isn't.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.
That is correct. I think we are saying the same thing, it is
CFRunLoop::run_current()
that is the problem.That really is unfortunate. I guess we will have to stick with a regular thread then for MacOS.
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.
yeah 😞 Reverted to an implementation similar to Windows ptal Thomas. Still, I think this approach makes sense and is more idiomatic the inicial one of overriding features