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

Clean up task sources and make all tasks cancellable #12404

Merged
merged 4 commits into from Jul 13, 2016

Conversation

@cbrewster
Copy link
Member

cbrewster commented Jul 12, 2016

This makes it so each task is a thin wrapper over a runnable and whenever a task is queued, it is automatically wrapped by the window's runnable_wrapper.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11703 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

Make tasks a wrapper over runnables
@highfive
Copy link

highfive commented Jul 12, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/htmltextareaelement.rs, components/script/dom/document.rs, components/script/task_source/user_interaction.rs, components/script/dom/storage.rs, components/script/network_listener.rs, components/script/dom/event.rs, components/script/dom/htmldetailselement.rs, components/script/dom/htmlformelement.rs, components/script/dom/htmlscriptelement.rs, components/script/dom/htmlmediaelement.rs, components/script/dom/htmlimageelement.rs, components/script/script_thread.rs, components/script/dom/htmlinputelement.rs, components/script/task_source/dom_manipulation.rs, components/script/task_source/mod.rs
@highfive
Copy link

highfive commented Jul 12, 2016

warning Warning warning

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

nox commented Jul 12, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 12, 2016

📌 Commit 6b0ce8e has been approved by nox

@highfive highfive assigned nox and unassigned asajeffrey Jul 12, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Jul 12, 2016

Testing commit 6b0ce8e with merge 0049ced...

bors-servo added a commit that referenced this pull request Jul 12, 2016
Clean up task sources and make all tasks cancellable

<!-- Please describe your changes on the following line: -->
This makes it so each task is a thin wrapper over a runnable and whenever a task is queued, it is automatically wrapped by the window's `runnable_wrapper`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./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: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

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

<!-- 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/12404)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 12, 2016

💔 Test failed - linux-rel

@jdm
Copy link
Member

jdm commented Jul 12, 2016

All the webstorage tests now time out, suggesting that something went wrong here :)

@cbrewster
Copy link
Member Author

cbrewster commented Jul 12, 2016

Woops, CancellableRunnable needed to implement the new Runnable methods to call the proper method on their inner runnable.

@cbrewster cbrewster force-pushed the cbrewster:task_source_cleanup branch from 8f565d8 to 714215c Jul 12, 2016
@asajeffrey
Copy link
Member

asajeffrey commented Jul 12, 2016

May fix #11703?

@asajeffrey asajeffrey self-assigned this Jul 13, 2016
@asajeffrey
Copy link
Member

asajeffrey commented Jul 13, 2016

Mostly this looks good, and yay for one less intermittent! My only question is about the amount of boxing we're doing, can we replace Box<T> by T?


Reviewed 1 of 9 files at r1, 1 of 3 files at r2, 12 of 13 files at r3, 1 of 1 files at r4, 1 of 1 files at r5.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/script/script_thread.rs, line 177 [r5] (raw file):

impl RunnableWrapper {
    pub fn wrap_runnable<T: Runnable + Send + 'static>(&self, runnable: Box<T>) -> Box<Runnable + Send> {

Why are we taking a Box<T> rather than a T as argument?


components/script/task_source/mod.rs, line 16 [r5] (raw file):

pub trait TaskSource {
    fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()>;

Why are we taking a Box<T> as an argument rather than a T?


Comments from Reviewable

@cbrewster
Copy link
Member Author

cbrewster commented Jul 13, 2016

Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/script/script_thread.rs, line 177 [r5] (raw file):

Previously, asajeffrey (Alan Jeffrey) wrote…

Why are we taking a Box<T> rather than a T as argument?

This doesn't end up boxing any more than usual, it just requires boxing the runnable before it reaches this point (as before this method boxed the runnable). I do think it is cleaner to have this method do the boxing rather than requiring the boxing to be done when the runnable is created.

components/script/task_source/mod.rs, line 16 [r5] (raw file):

Previously, asajeffrey (Alan Jeffrey) wrote…

Why are we taking a Box<T> as an argument rather than a T?

Same as above.

Comments from Reviewable

Implement all Runnable methods on CancellableRunnable to redirect to their inner runnable
@cbrewster cbrewster force-pushed the cbrewster:task_source_cleanup branch from 2b42b8f to 523cd73 Jul 13, 2016
@asajeffrey
Copy link
Member

asajeffrey commented Jul 13, 2016

Review status: 5 of 16 files reviewed at latest revision, 2 unresolved discussions.


components/script/script_thread.rs, line 177 [r5] (raw file):

Previously, ConnorGBrewster (Connor Brewster) wrote…

This doesn't end up boxing any more than usual, it just requires boxing the runnable before it reaches this point (as before this method boxed the runnable). I do think it is cleaner to have this method do the boxing rather than requiring the boxing to be done when the runnable is created.

I meant why are we doing any boxing?

Comments from Reviewable

@KiChjang
Copy link
Member

KiChjang commented Jul 13, 2016

@asajeffrey Because Runnable is a trait, and you cannot have a trait as an argument type.

@cbrewster cbrewster force-pushed the cbrewster:task_source_cleanup branch from 523cd73 to 862dc00 Jul 13, 2016
@asajeffrey
Copy link
Member

asajeffrey commented Jul 13, 2016

Reviewed 10 of 11 files at r8, 1 of 1 files at r9.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/script/script_thread.rs, line 177 [r5] (raw file):

Previously, asajeffrey (Alan Jeffrey) wrote…

I meant why are we doing any boxing?

IRC conversation: http://logs.glob.uno/?c=mozilla%23servo&s=13+Jul+2016&e=13+Jul+2016#c479392

Comments from Reviewable

@asajeffrey
Copy link
Member

asajeffrey commented Jul 13, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 13, 2016

📌 Commit 862dc00 has been approved by asajeffrey

@bors-servo
Copy link
Contributor

bors-servo commented Jul 13, 2016

Testing commit 862dc00 with merge 3011d4b...

bors-servo added a commit that referenced this pull request Jul 13, 2016
Clean up task sources and make all tasks cancellable

<!-- Please describe your changes on the following line: -->
This makes it so each task is a thin wrapper over a runnable and whenever a task is queued, it is automatically wrapped by the window's `runnable_wrapper`.

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

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

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

<!-- 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/12404)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 13, 2016

@bors-servo bors-servo merged commit 862dc00 into servo:master Jul 13, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@metajack metajack mentioned this pull request Jul 13, 2016
8 of 18 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.