Futures can currently be cancelled only by dropping the instance. It would be useful to be able cancel them individually.
As an example, if you write a C++ RAII wrapper around a WGPUFuture (say, myapp::WebGPUFuture<wgpu::ComputePipeline>) and you drop it, there's no way to ensure the callback gets called except to wait for the future. If we had a way to cancel futures like void wgpuInstanceCancelFuture(WGPUFuture)1, you could do that instead - basically, call the callback immediately and ignore/abort any ongoing work.
Right now we already have the InstanceDropped status, I think we could genericize this to Canceled/Cancelled2 and use it for this too.
Futures can currently be cancelled only by dropping the instance. It would be useful to be able cancel them individually.
As an example, if you write a C++ RAII wrapper around a
WGPUFuture(say,myapp::WebGPUFuture<wgpu::ComputePipeline>) and you drop it, there's no way to ensure the callback gets called except to wait for the future. If we had a way to cancel futures likevoid wgpuInstanceCancelFuture(WGPUFuture)1, you could do that instead - basically, call the callback immediately and ignore/abort any ongoing work.Right now we already have the
InstanceDroppedstatus, I think we could genericize this toCanceled/Cancelled2 and use it for this too.Footnotes
This function could have a return value indicating whether it actually got canceled, though it seems probably not necessary because you'll get the status via the callback. ↩
though I dislike this word because its spelling is ambiguous, similar to adapter vs adaptor ↩