gstreamer_vulkan/
vulkan_command_pool.rs

1use crate::VulkanCommandPool;
2
3use glib::{prelude::*, translate::*};
4
5// rustdoc-stripper-ignore-next
6/// Represents a locked VulkanCommandPool. The command pool is unlocked when this struct is dropped.
7#[derive(Debug)]
8pub struct VulkanCommandPoolGuard<'a> {
9    obj: &'a VulkanCommandPool,
10}
11
12impl Drop for VulkanCommandPoolGuard<'_> {
13    fn drop(&mut self) {
14        unsafe {
15            ffi::gst_vulkan_command_pool_unlock(self.obj.to_glib_none().0);
16        }
17    }
18}
19impl PartialEq for VulkanCommandPoolGuard<'_> {
20    fn eq(&self, other: &Self) -> bool {
21        self.obj == other.obj
22    }
23}
24impl Eq for VulkanCommandPoolGuard<'_> {}
25
26pub trait VulkanCommandPoolExtManual: IsA<VulkanCommandPool> + 'static {
27    // rustdoc-stripper-ignore-next
28    /// Locks the command pool. A struct similar to `MutexGuard` is retured that unlocks the command pool once dropped.
29    // rustdoc-stripper-ignore-next-stop
30    /// This should be called to ensure no other thread will attempt to access
31    /// the pool's internal resources. Any modification of any of the allocated
32    /// [`VulkanCommandBuffer`][crate::VulkanCommandBuffer]'s need to be encapsulated in a
33    /// [`lock()`][Self::lock()]/[`unlock()`][Self::unlock()] pair to meet
34    /// the Vulkan API requirements that host access to the command pool is
35    /// externally synchronised.
36    #[doc(alias = "gst_vulkan_command_pool_lock")]
37    fn lock<'a>(&'a self) -> VulkanCommandPoolGuard<'a> {
38        unsafe {
39            ffi::gst_vulkan_command_pool_lock(self.as_ref().to_glib_none().0);
40        }
41        VulkanCommandPoolGuard {
42            obj: self.upcast_ref(),
43        }
44    }
45}
46impl<O: IsA<VulkanCommandPool>> VulkanCommandPoolExtManual for O {}