Skip to content

Introduce a custom DOMRefCell<T> - #3574

Closed
tetsuharuohzeki wants to merge 4 commits into
servo:masterfrom
tetsuharuohzeki:cell
Closed

tetsuharuohzeki wants to merge 4 commits into
servo:masterfrom
tetsuharuohzeki:cell

Conversation

@tetsuharuohzeki

Copy link
Copy Markdown
Contributor

@hoppipolla-critic-bot

Copy link
Copy Markdown

Critic review: https://critic.hoppipolla.co.uk/r/2768

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@highfive

highfive commented Oct 5, 2014

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@tetsuharuohzeki

Copy link
Copy Markdown
Contributor Author

I'm working to use DOMRefCell<T>.borrow_in_layout() instead of mem::transmute(&self.bar), like:

let attrs: *const Vec<JS<Attr>> = mem::transmute(*self.attrs.borrow_in_layout());

But this approach will causes some errors: task 'LayoutWorker' failed at 'assertion failed: borrow != WRITING && borrow != UNUSED', /Users/larsberg/rust/src/libcore/cell.rs:338.

In DOMRefCell<T>.borrow_in_layout(), should we only check whether the value is borrowed in layout or not, don't check whether the borrowed value is mutated or not?

@jdm

jdm commented Oct 7, 2014

Copy link
Copy Markdown
Member

Right, I think this patch might be going about the process the wrong way. We cannot and must not call the borrow method in the layout task. Instead of reimplementing RefCell, I think DOMRefCell should wrap a RefCell internally and the layout task's borrow method should perform the transmute itself and return &T, while the script task's borrow methods should return a Ref/RefMut<T>.

@tetsuharuohzeki

Copy link
Copy Markdown
Contributor Author

Right, I think this patch might be going about the process the wrong way. We cannot and must not call the borrow method in the layout task.

Umm. it was as I suspected.

DOMRefCell should wrap a RefCell internally and the layout task's borrow method should perform the transmute itself and return &T

Ok. I'll try the such approach.

@tetsuharuohzeki
tetsuharuohzeki force-pushed the cell branch 2 times, most recently from 0ed3f37 to 024e8c4 Compare October 14, 2014 19:26
@tetsuharuohzeki

Copy link
Copy Markdown
Contributor Author

@jdm r?

@tetsuharuohzeki
tetsuharuohzeki force-pushed the cell branch 2 times, most recently from 51104cd to a884b36 Compare October 15, 2014 04:38
Tetsuharu OHZEKI added 4 commits October 15, 2014 13:41
This type simply wraps `RefCell<T>` to add the special method,
and introduce the method to return the pointer of the value contained in
itself, for used in layout task.
@tetsuharuohzeki

Copy link
Copy Markdown
Contributor Author

rebased on master & squashed!

bors-servo pushed a commit that referenced this pull request Oct 15, 2014
@bors-servo bors-servo closed this Oct 15, 2014
@tetsuharuohzeki
tetsuharuohzeki deleted the cell branch October 15, 2014 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants