Add boxed_send(), boxed_sync(), boxed_send_sync() for GpuFuture (#1802)

This commit is contained in:
Todd York 2022-01-30 00:58:51 +08:00 committed by GitHub
parent d36bba1a2c
commit be4e5dc678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -291,6 +291,36 @@ pub unsafe trait GpuFuture: DeviceOwned {
{
Box::new(self) as _
}
/// Turn the current future into a `Box<dyn GpuFuture + Send>`.
///
/// This is a helper function that calls `Box::new(yourFuture) as Box<dyn GpuFuture + Send>`.
fn boxed_send(self) -> Box<dyn GpuFuture + Send>
where
Self: Sized + Send + 'static,
{
Box::new(self) as _
}
/// Turn the current future into a `Box<dyn GpuFuture + Sync>`.
///
/// This is a helper function that calls `Box::new(yourFuture) as Box<dyn GpuFuture + Sync>`.
fn boxed_sync(self) -> Box<dyn GpuFuture + Sync>
where
Self: Sized + Sync + 'static,
{
Box::new(self) as _
}
/// Turn the current future into a `Box<dyn GpuFuture + Send + Sync>`.
///
/// This is a helper function that calls `Box::new(yourFuture) as Box<dyn GpuFuture + Send + Sync>`.
fn boxed_send_sync(self) -> Box<dyn GpuFuture + Send + Sync>
where
Self: Sized + Send + Sync + 'static,
{
Box::new(self) as _
}
}
unsafe impl<F: ?Sized> GpuFuture for Box<F>