-
Notifications
You must be signed in to change notification settings - Fork 629
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
Remove StreamObj, caution against using FutureObj #1494
Conversation
#[cfg(feature = "alloc")] | ||
/// An owned dynamically typed [`Future`] for use in cases where you can't | ||
/// statically type your result or need to add some indirection. | ||
pub type BoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + Send + 'a>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to see non-Send
versions of these-- maybe BoxFutureLocal
? unsure-- we can sort that out in a separate change :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(similarly, adding a boxed_local
would be great)
Why not remove |
futures/tests/futures_unordered.rs
Outdated
@@ -68,8 +67,8 @@ fn finished_future() { | |||
let (c_tx, c_rx) = oneshot::channel::<i32>(); | |||
|
|||
let mut stream = futures_unordered(vec![ | |||
FutureObj::new(Box::new(a_rx)), | |||
//FutureObj::new(Box::new(b_rx.select(c_rx))), | |||
a_rx.boxed() as BoxFuture<_>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... I kind of think we should change the default return of boxed
to the trait-object version to make this cast unnecessary. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, if users want a non-trait-object they can call Box::new
themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with this is that BoxFuture
can't actually be directly converted to FutureObj
because of #1535, which is why https://github.com/rust-lang-nursery/futures-rs/pull/1494/files#diff-57ad78f21e9043ebe29659ff5d335774R9 was necessary. I've got a fix for #1535 ready to open once this is merged (it requires an enhancement to the Pin
API so will be blocked on a rust
PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change exacerbates the issue from #1535 since FutureExt::boxed
now returns BoxFuture
and FutureObj::new
can’t take a BoxFuture
since it doesn’t support boxed unsized values.
Nemo157@b436178 is the change I’m referring to which will allow converting a BoxFuture
to a FutureObj
, that’s the one using the Pin
api changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the API changes I was referring to are rust-lang/rust#60165, they can be worked around similar to the old code if we want to get a stable release out for 1.36.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, would you like to go ahead and land this change, or would you prefer to hold off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think landing this as is is fine, I'll open a PR for that other change straight away so it can be merged once rust-lang/rust#60165 is (or updated to work around it), I just didn't do it as a parallel PR as it would definitely have merge conflicts with this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg, merged this one.
Apologies for the delay in reviewing this! |
(I need to keep a better eye on the repo-- or perhaps we should set up something bors-like so that I can get notifications-- I guess pinging me on the thread would also accomplish this goal) |
-- Having bors here would also be useful for merging multiple PRs (I assume you're using the admin override to merge without CI passing, I can only merge a PR if it's up to date with master because of CI limitations). |
2bf5e98
to
69cf4ab
Compare
Fixes #1352