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

layout/context: Wrap `image_cache_thread` in a `Mutex<>` as well #14048

Merged
merged 1 commit into from Nov 4, 2016

Conversation

@antrik
Copy link
Contributor

antrik commented Nov 3, 2016

SharedLayoutContext.image_cache_thread didn't get the Mutex<>
treatment along with all the other channels in there, because
ipc-channel::Sender is presently inherently Sync. I believe this to
be an implementation accident though, that should be rectified in the
future -- not something users should actually rely on...

Note that sharing senders (be it mpsc or ipc-channel) in is probably
not a good idea anyway: just cloning them -- and letting them handle the
sharing internally -- should be both simpler and cheaper. But right now
that's how things are handled here; so let's go with the flow...


This change is Reviewable

`SharedLayoutContext.image_cache_thread` didn't get the `Mutex<>`
treatment along with all the other channels in there, because
`ipc-channel::Sender` is presently inherently `Sync`. I believe this to
be an implementation accident though, that should be rectified in the
future -- not something users should actually rely on...

Note that sharing senders (be it `mpsc` or `ipc-channel`) in is probably
not a good idea anyway: just cloning them -- and letting them handle the
sharing internally -- should be both simpler and cheaper. But right now
that's how things are handled here; so let's go with the flow...
@highfive
Copy link

highfive commented Nov 3, 2016

Heads up! This PR modifies the following files:

  • @emilio: components/layout/context.rs
@highfive
Copy link

highfive commented Nov 3, 2016

warning Warning warning

  • These commits modify layout code, but no tests are modified. Please consider adding a test!
@antrik
Copy link
Contributor Author

antrik commented Nov 3, 2016

Not a real failure there, just a hiccup as far as I can tell.

@mbrubeck
Copy link
Contributor

mbrubeck commented Nov 3, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Nov 3, 2016

📌 Commit 4d14f1e has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Nov 4, 2016

Testing commit 4d14f1e with merge 7b80386...

bors-servo added a commit that referenced this pull request Nov 4, 2016
layout/context: Wrap `image_cache_thread` in a `Mutex<>` as well

`SharedLayoutContext.image_cache_thread` didn't get the `Mutex<>`
treatment along with all the other channels in there, because
`ipc-channel::Sender` is presently inherently `Sync`. I believe this to
be an implementation accident though, that should be rectified in the
future -- not something users should actually rely on...

Note that sharing senders (be it `mpsc` or `ipc-channel`) in is probably
not a good idea anyway: just cloning them -- and letting them handle the
sharing internally -- should be both simpler and cheaper. But right now
that's how things are handled here; so let's go with the flow...

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

bors-servo commented Nov 4, 2016

@bors-servo bors-servo merged commit 4d14f1e into servo:master Nov 4, 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
bors-servo added a commit to servo/ipc-channel that referenced this pull request Nov 7, 2016
Don't make `OsIpcSender` `Sync`

`mpsc::Sender` isn't `Sync` -- and the `ipc-channel` equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the `inprocess` back-end, implementing `Sync` was necessitating
use of an `Arc<Mutex<>>`, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit `Sync` claim.

For the `macos` and `unix` back-ends, the sender implementations were
inherently `Sync`; so we explicitly mark them `!Sync` now, to get a
consistent API.

Also bumping the `ipc-channel` version here, as this is a breaking
change.

(It affects Servo only in one place though, see servo/servo#14048 )

This also comes with a test case to verify that `OsIpcSender` indeed isn't `Sync` any more; and a CI change to activate it.
bors-servo added a commit to servo/ipc-channel that referenced this pull request Nov 8, 2016
Don't make `OsIpcSender` `Sync`

`mpsc::Sender` isn't `Sync` -- and the `ipc-channel` equivalent probably
shouldn't be either. Sharing references to senders is usually not a good
idea: they are rather meant to be cloned instead; and they implement
internal sharing to make this efficient and robust -- sharing references
to senders just adds an unnecessary extra layer of sharing on top.

For the `inprocess` back-end, implementing `Sync` was necessitating
use of an `Arc<Mutex<>>`, adding considerable overhead even when not
used -- so this change is an optimisation. It effectively reverts most
of the sender part of 30b2024 (the
receiver part was already backed out in
77469c2 ), except that it obviously
doesn't re-introduce the bogus explicit `Sync` claim.

For the `macos` and `unix` back-ends, the sender implementations were
inherently `Sync`; so we explicitly mark them `!Sync` now, to get a
consistent API.

Also bumping the `ipc-channel` version here, as this is a breaking
change.

(It affects Servo only in one place though, see servo/servo#14048 )

This also comes with a test case to verify that `OsIpcSender` indeed isn't `Sync` any more; and a CI change to activate it.
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

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