-
Notifications
You must be signed in to change notification settings - Fork 18
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
Future::spawn
should not require 'static
#3
Comments
I have not yet done an audit of all the lifetimes (the code predates |
I started work on a PR, then realized that this |
@apoelstra There may be a way to rewrite |
Oh, awesome @carllerche , I think you're right. I'll try to write such a PR tonight. Right now I am doing some really nasty unsafe trickery to extend the lifetimes of some borrows to And thanks for this library by the way! |
I think I'm blocked on rust-lang/rust#23992 -- if I add a lifetime parameter to
(You can see that |
Indeed, I've definitely hit a few ICEs working on Eventual. We should also think about how adding a lifetime will affect the common usage patters of |
My thinking is, it would almost always be elided, and be equal to the shortest lifetime of the things captured in the closure. In practice this would look something like
that is, a simple fork-then-join algorithm entirely contained in one block. I think this is the most common use of This is what I'm doing in The cases where elision wouldn't occur would be like, defining a struct with a |
Given rust-lang/rust#24292 I'm going to close this for now. This should probably be recreated in the future once |
There are two
'static
bounds on the implementation ofFuture::spawn
. One is thatT: 'static
, which I think is actually unnecessary. Edit: Actually I think it is, though maybe I'm just not seeing a clever way to avoid it.The other is that
F: FnOnce() -> T + Send + 'static
, which can be weakened to a parameter lifetime'a
provided you add aPhantomData
marker toFuture
tying'a
to the lifetime of theFuture
itself. (I'm assuming here that theDrop
impl onFuture
ends the async thread before completing; is this true?)The text was updated successfully, but these errors were encountered: