Skip to content

FutureObj doesn't support ?Sized types #1535

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

Closed
Nemo157 opened this issue Apr 18, 2019 · 1 comment
Closed

FutureObj doesn't support ?Sized types #1535

Nemo157 opened this issue Apr 18, 2019 · 1 comment

Comments

@Nemo157
Copy link
Member

Nemo157 commented Apr 18, 2019

FutureObj requires a static vtable in the form of trait UnsafeFutureObj, this blocks being able to provide a conversion from Box<dyn Future<Output = ()>> to FutureObj<'static, ()> which would be useful for more optimized spawning.

I think one way to handle this would be to change FutureObj to directly contain a fat-pointer for the future + a function pointer for how to drop it (which can be statically determined by the concrete type containing the dyn Future when it's being converted to the FutureObj). That should be the same size as the existing implementation as the current poll_fn pointer is being replaced with the vtable pointer in the dyn Future. I guess it will require one more pointer lookup to find the poll_fn pointer in the vtable though...

pub struct LocalFutureObj<'a, T> {
    future: *mut dyn Future<Output = T>,
    drop_fn: unsafe fn(*mut dyn Future<Output = T>),
    _marker: PhantomData<&'a ()>,
}
@Nemo157
Copy link
Member Author

Nemo157 commented Apr 27, 2019

Fixed by #1550

@Nemo157 Nemo157 closed this as completed Apr 27, 2019
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

No branches or pull requests

1 participant