gstreamer_vulkan/
vulkan_command_pool.rs

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