-
Notifications
You must be signed in to change notification settings - Fork 2
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
Turning reference of Future to Future of reference #4
Comments
Hm, I'll have to think about it. I suspect it will be hard to get right, because of the lifetime of the &mut T references have to outlive the Future, and some Future/Promise methods require the values to have |
Further thoughts: Operations on I think if you have a Can you go into a bit more detail about what your actual code is doing? |
I am trying to create voxel based game engine, where I am generating/loading chunks concurrently. But if something happens that needs to set/get block in a chunk that is not loaded/generated I have to wait for it to do. So basically I am currently treating Future like permanent container that just might not have the value right now. |
Actually having method that returns mutable reference to value inside would be enough. |
Yeah, right now you'd need to pull the Future out and put it back, or put the real value back (ie, have some enum type which is either a Changing the Future to return references to its internals is a bit of a design change, but I'll see how much impact it has. |
I added |
Using |
I don't see it as a limitation. A Now that there's the _ref methods, it can be a building block to compose other functionality on top. |
Maybe I am not seeing the whole picture, but I don't understand what prevents just adding enum MaybeFuture<T> {
Future(Future<T>),
Value(T),
} |
Is there a way or can a way be added to to turn &mut Future to Future<&mut T> and the same with shared references?
I have a hash map that maps key to a future. I populate this map in background with threadpool, but in certain situations I want to access future immediately.
So I am using HashMaps entry API to do the processing in the main thread:
Best name for the method would propably be
as_mut
as that is what Options equivalent method is called.The text was updated successfully, but these errors were encountered: