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

Update to new futures_api #1514

Merged
merged 2 commits into from
Apr 15, 2019
Merged

Update to new futures_api #1514

merged 2 commits into from
Apr 15, 2019

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Apr 7, 2019

This PR covers changes by rust-lang/rust#59119 and rust-lang/rust#59733.

cc #1518 (I initially intended to close it with this PR, but in fact it might be better to close it when the next version is released.)

@taiki-e taiki-e marked this pull request as ready for review April 8, 2019 03:37
@taiki-e taiki-e force-pushed the futures_api branch 3 times, most recently from 3fa1ec0 to 1c646d9 Compare April 8, 2019 04:05
@taiki-e taiki-e changed the title [WIP] Update to new futures_api Update to new futures_api Apr 8, 2019
@taiki-e taiki-e force-pushed the futures_api branch 5 times, most recently from 2fe2457 to c2249c7 Compare April 8, 2019 05:23
@yoshuawuyts
Copy link
Member

Is there an ETA when we could land this? The changes have landed in the latest nightly, and currently a good amount of packages are broken until we can land this.

@taiki-e
Copy link
Member Author

taiki-e commented Apr 11, 2019

(Landing it now does not mean that we can immediately release the next version.)

@taiki-e
Copy link
Member Author

taiki-e commented Apr 11, 2019

Also, rust-lang/rust#59733 is already approved, so It will break again in a few days.

@davidbarsky
Copy link

Possibly a ignorant question, but would this fix land (pending time/availability from people, naturally) when/if rust-lang/rust@df25d79 is part of a nightly release?

@taiki-e
Copy link
Member Author

taiki-e commented Apr 13, 2019

@cramertj @Nemo157 Could you review this PR?

Considering FCP takes more than a week, I think that it is preferable to land this at this timing.

@najamelan
Copy link
Contributor

Updating to nightly today still gave me another error:

error[E0507]: cannot move out of borrowed content
   --> /futures-rs/futures-core/src/task/__internal/atomic_waker.rs:244:17
    |
244 |                 waker.wake();
    |                 ^^^^^ cannot move out of borrowed content

Not entirely sure that this should be dealt with in this pull request, but I think it's because of the waker by ref last minute changes before stabelization. Cloning it here was my fast braindead fix, but I don't know whether that's the best way to solve this.

@taiki-e
Copy link
Member Author

taiki-e commented Apr 13, 2019

@najamelan See 265ca12.

@najamelan
Copy link
Contributor

@taiki-e Oh, sorry, you're awesome. I had missed the extra commit... compiles fine. Thanks

Copy link
Member

@Nemo157 Nemo157 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for updating this all.

Everything except the one comment I've left looks like a straight-forward update of the API, there's potentially some performance optimization that could be done using the by-value waking, but that would be best as a separate PR.

/// This function is similar to `wake`, but must not consume the provided data
/// pointer.
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.clone().wake()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain whether it makes sense to keep the separation of waking by-value and by-ref for ArcWake, it looks like every implementation of ArcWake::wake delegates to ArcWake::wake_by_ref. But maybe the thread pool implementation can be updated to take advantage of it.

I think it makes more sense to provide the ArcWake::wake implementation as delegating to ArcWake::wake_by_ref, that would allow dropping all the current delegating implementations, and means that implementors wouldn't accidentally cause an unnecessary clone by only implementing ArcWake::wake (they may still cause an unnecessary clone by only implementing ArcWake::wake_by_ref and not taking advantage of being able to reuse the Arc in ArcWake::wake, but that seems like a more obvious performance issue since the clone will be happening in their code instead of the provided method).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense to provide the ArcWake::wake implementation as delegating to ArcWake::wake_by_ref, that would allow dropping all the current delegating implementations, and means that implementors wouldn't accidentally cause an unnecessary clone by only implementing ArcWake::wake (they may still cause an unnecessary clone by only implementing ArcWake::wake_by_ref and not taking advantage of being able to reuse the Arc in ArcWake::wake, but that seems like a more obvious performance issue since the clone will be happening in their code instead of the provided method).

Thanks for pointing that out, that makes a lot of sense.

@Nemo157
Copy link
Member

Nemo157 commented Apr 15, 2019

(for others that want to start experimenting off this, here's a block you can copy-paste into your Cargo.toml to set all the overrides):

[patch.crates-io]
futures-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-core-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-util-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-sink-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-channel-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-executor-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-io-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }
futures-test-preview = { git = "https://github.com/taiki-e/futures-rs", branch = "futures_api" }

@Nemo157 Nemo157 merged commit e648614 into rust-lang:master Apr 15, 2019
@Nemo157
Copy link
Member

Nemo157 commented Apr 15, 2019

Thanks again ❤️, hopefully we can get a release out soon with these fixes in (maybe even one worth promoting to beta).

@cramertj
Copy link
Member

Thanks for working to get this landed! All the help is extremely appreciated. I'll get a new release out ASAP.

@vorot93
Copy link
Contributor

vorot93 commented Apr 15, 2019

@cramertj Could you please take a look at #1524 at first? google/tarpc may miss the new release otherwise.

@cramertj
Copy link
Member

@vorot93 merged! :) (In the future, cc'ing me or adding me as a reviewer will get my attention quicker, though I try to scan the repo for PRs every once in a while)

@taiki-e taiki-e deleted the futures_api branch April 15, 2019 18:26
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.

7 participants