script: implement navigator.hardwareConcurrency - #31268
Merged
Merged
Conversation
Taym95
reviewed
Feb 6, 2024
| mime_guess = { workspace = true } | ||
| msg = { workspace = true } | ||
| net_traits = { workspace = true } | ||
| num_cpus = "1.1.0" |
Member
There was a problem hiding this comment.
Maybe is good to create an issue and link this PR
Contributor
Author
There was a problem hiding this comment.
Do you mean I should create an issue in num_cpus? I don't see why this PR would warrant creating an issue.
mrobinson
requested changes
Feb 7, 2024
| use crate::dom::xrsystem::XRSystem; | ||
| use crate::script_runtime::JSContext; | ||
|
|
||
| pub(super) fn hardware_concurrency() -> u64 { |
Member
There was a problem hiding this comment.
Why is this function public? Could it simply be moved into the body of HardwareConcurrency(&self)? Since the code is not repeated, I'm not sure an extra function buys us much unless I'm misunderstanding.
Contributor
Author
There was a problem hiding this comment.
It's also called in components/script/dom/workernavigator.rs - I split it out to another function to avoid duplicating the logic in the Navigator and WorkerNavigator.
Signed-off-by: syvb <me@iter.ca>
syvb
force-pushed
the
hardware-concurrency
branch
from
February 7, 2024 13:11
01f96a8 to
382cf13
Compare
mrobinson
approved these changes
Feb 7, 2024
Taym95
pushed a commit
to Taym95/servo
that referenced
this pull request
Feb 11, 2024
Signed-off-by: syvb <me@iter.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements
navigator.hardwareConcurrency, which returns the number of logical processors available.I used the
num_cpuslibrary (which is already used by Servo in other places), and cache the result since it can be slow to query that information on some operating systems../mach build -ddoes not report any errors./mach test-tidydoes not report any errors