wgpu_async/
async_queue.rs1use crate::{async_device::AsyncDevice, WgpuFuture};
2use std::{ops::Deref, sync::Arc};
3use wgpu::{CommandBuffer, Queue};
4
5#[derive(Clone, Debug)]
8pub struct AsyncQueue {
9 device: AsyncDevice,
10 queue: Arc<Queue>,
11}
12
13impl AsyncQueue {
14 pub(crate) fn new(device: AsyncDevice, queue: Arc<Queue>) -> Self {
15 Self { device, queue }
16 }
17
18 pub fn submit<I: IntoIterator<Item = CommandBuffer>>(
23 &self,
24 command_buffers: I,
25 ) -> WgpuFuture<()> {
26 let queue_ref = Arc::clone(&self.queue);
27
28 queue_ref.submit(command_buffers);
29
30 self.device.do_async(move |callback| {
31 queue_ref.on_submitted_work_done(|| callback(()));
32 })
33 }
34
35 pub fn device(&self) -> &AsyncDevice {
37 &self.device
38 }
39}
40impl Deref for AsyncQueue {
41 type Target = wgpu::Queue;
42
43 fn deref(&self) -> &Self::Target {
44 &self.queue
45 }
46}
47impl<T> AsRef<T> for AsyncQueue
48where
49 T: ?Sized,
50 <AsyncQueue as Deref>::Target: AsRef<T>,
51{
52 fn as_ref(&self) -> &T {
53 self.deref().as_ref()
54 }
55}