mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 23:34:29 +00:00
[wgpu-hal] Change the DropCallback
API to use FnOnce
instead of FnMut
(#6482)
This commit is contained in:
parent
6b85e65f51
commit
4e47ba4ac0
@ -46,6 +46,12 @@ Bottom level categories:
|
||||
|
||||
- Parse `diagnostic(…)` directives, but don't implement any triggering rules yet. By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456).
|
||||
|
||||
### Changes
|
||||
|
||||
#### HAL
|
||||
|
||||
- Change the `DropCallback` API to use `FnOnce` instead of `FnMut`. By @jerzywilczek in [#6482](https://github.com/gfx-rs/wgpu/pull/6482)
|
||||
|
||||
## 23.0.0 (2024-10-25)
|
||||
|
||||
### Themes of this release
|
||||
|
@ -305,24 +305,28 @@ pub type AtomicFenceValue = std::sync::atomic::AtomicU64;
|
||||
|
||||
/// A callback to signal that wgpu is no longer using a resource.
|
||||
#[cfg(any(gles, vulkan))]
|
||||
pub type DropCallback = Box<dyn FnMut() + Send + Sync + 'static>;
|
||||
pub type DropCallback = Box<dyn FnOnce() + Send + Sync + 'static>;
|
||||
|
||||
#[cfg(any(gles, vulkan))]
|
||||
pub struct DropGuard {
|
||||
callback: DropCallback,
|
||||
callback: Option<DropCallback>,
|
||||
}
|
||||
|
||||
#[cfg(all(any(gles, vulkan), any(native, Emscripten)))]
|
||||
impl DropGuard {
|
||||
fn from_option(callback: Option<DropCallback>) -> Option<Self> {
|
||||
callback.map(|callback| Self { callback })
|
||||
callback.map(|callback| Self {
|
||||
callback: Some(callback),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(gles, vulkan))]
|
||||
impl Drop for DropGuard {
|
||||
fn drop(&mut self) {
|
||||
(self.callback)();
|
||||
if let Some(cb) = self.callback.take() {
|
||||
(cb)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user