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

style: Make WorkQueue creation fallible. #13041

Merged
merged 1 commit into from Aug 26, 2016

Conversation

@emilio
Copy link
Member

emilio commented Aug 25, 2016


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • These changes do not require tests.

Fixes bug 1290205 in bugzilla.


This change is Reviewable

@highfive
Copy link

highfive commented Aug 25, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/workqueue.rs
@highfive
Copy link

highfive commented Aug 25, 2016

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!
@emilio
Copy link
Member Author

emilio commented Aug 25, 2016

@highfive highfive assigned bholley and unassigned glennw Aug 25, 2016
@@ -276,21 +277,42 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> {
}

// Spawn threads.
let mut thread_handles = vec![];

This comment has been minimized.

@bholley

bholley Aug 26, 2016

Contributor

What is the difference between vec![] and vec!()?

This comment has been minimized.

@KiChjang

KiChjang Aug 26, 2016

Member

No difference, it's just personal style.

This comment has been minimized.

@bholley

bholley Aug 26, 2016

Contributor

Seems like we should specify one or the other in the style guide.

This comment has been minimized.

@emilio

emilio Aug 26, 2016

Author Member

I use to prefer vec![] because it mimics the style of arrays and slices (with the square brackets). But yeah, you can use whatever you want.

// rest of them, and return an error.
for (i, handle) in thread_handles.into_iter().enumerate() {
let _ = infos[i].chan.send(WorkerMsg::Exit);
let _ = handle.join();

This comment has been minimized.

@bholley

bholley Aug 26, 2016

Contributor

Could we make the thread handle vec an RAII class instead which automatically exits and joins the threads? That would allow us to return directly from the error case rather than doing the somewhat-wonky length check.

This comment has been minimized.

@emilio

emilio Aug 26, 2016

Author Member

Hm... Not really, or at least not in a way that's easier than this (because otherwise the threads will be joined when the function returns). Of course we could carry it with the queue, or adding a method to the handle wrapper so it detached it, but I don't think it's simpler than this.

@@ -68,7 +68,7 @@ impl PerDocumentStyleData {
new_animations_receiver: new_anims_receiver,
running_animations: Arc::new(RwLock::new(HashMap::new())),
expired_animations: Arc::new(RwLock::new(HashMap::new())),
work_queue: WorkQueue::new("StyleWorker", thread_state::LAYOUT, *NUM_THREADS),
work_queue: WorkQueue::new("StyleWorker", thread_state::LAYOUT, *NUM_THREADS).ok(),

This comment has been minimized.

@bholley

bholley Aug 26, 2016

Contributor

While you're here, can we also avoid spawning the queue if num_threads is 1?

@bholley
Copy link
Contributor

bholley commented Aug 26, 2016

You rock. :-)

r=me with comments addressed. @bors-servo delegate+

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

✌️ @emilio can now approve this pull request

Fixes bug 1290205 in bugzilla.
@emilio emilio force-pushed the emilio:fallible-threadpool branch from 2014290 to 4194ba0 Aug 26, 2016
@emilio
Copy link
Member Author

emilio commented Aug 26, 2016

@bors-servo: r=bholley

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

📌 Commit 4194ba0 has been approved by bholley

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

Testing commit 4194ba0 with merge 911bc94...

bors-servo added a commit that referenced this pull request Aug 26, 2016
style: Make WorkQueue creation fallible.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [x] These changes do not require tests.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Fixes bug 1290205 in bugzilla.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13041)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

💔 Test failed - linux-rel

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 26, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

Previous build results for arm32, arm64, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2016

@bors-servo bors-servo merged commit 4194ba0 into servo:master Aug 26, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.