-
Notifications
You must be signed in to change notification settings - Fork 131
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
Don't make OsIpcSender
Sync
#115
Conversation
`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.
Unfortunately this requires an "unstable" feature to be enabled, because it relies on specialization... Can't think of any other way to handle this.
I'm wondering whether maybe it would be better to squash these commits; or some of them at least?... |
Have you tried https://github.com/laumann/compiletest-rs? That strikes me as the simplest way to make sure |
@pcwalton with lots of tears and sweat, I managed to get it working with However, |
@bors-servo: r+ |
📌 Commit ad19e55 has been approved by |
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.
💔 Test failed - status-appveyor |
@bors-servo retry |
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.
☀️ Test successful - status-appveyor, status-travis |
mpsc::Sender
isn'tSync
-- and theipc-channel
equivalent probablyshouldn'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, implementingSync
was necessitatinguse of an
Arc<Mutex<>>
, adding considerable overhead even when notused -- 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
andunix
back-ends, the sender implementations wereinherently
Sync
; so we explicitly mark them!Sync
now, to get aconsistent API.
Also bumping the
ipc-channel
version here, as this is a breakingchange.
(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'tSync
any more; and a CI change to activate it.