gstreamer_vulkan/vulkan_command_pool.rs
1use crate::VulkanCommandPool;
2use crate::ffi;
3
4use glib::{prelude::*, translate::*};
5
6// rustdoc-stripper-ignore-next
7/// Represents a locked VulkanCommandPool. The command pool is unlocked when this struct is dropped.
8#[derive(Debug)]
9pub struct VulkanCommandPoolGuard<'a> {
10 obj: &'a VulkanCommandPool,
11}
12
13impl Drop for VulkanCommandPoolGuard<'_> {
14 fn drop(&mut self) {
15 unsafe {
16 ffi::gst_vulkan_command_pool_unlock(self.obj.to_glib_none().0);
17 }
18 }
19}
20impl PartialEq for VulkanCommandPoolGuard<'_> {
21 fn eq(&self, other: &Self) -> bool {
22 self.obj == other.obj
23 }
24}
25impl Eq for VulkanCommandPoolGuard<'_> {}
26
27pub trait VulkanCommandPoolExtManual: IsA<VulkanCommandPool> + 'static {
28 // rustdoc-stripper-ignore-next
29 /// Locks the command pool. A struct similar to `MutexGuard` is retured that unlocks the command pool once dropped.
30 #[doc(alias = "gst_vulkan_command_pool_lock")]
31 fn lock<'a>(&'a self) -> VulkanCommandPoolGuard<'a> {
32 unsafe {
33 ffi::gst_vulkan_command_pool_lock(self.as_ref().to_glib_none().0);
34 }
35 VulkanCommandPoolGuard {
36 obj: self.upcast_ref(),
37 }
38 }
39}
40impl<O: IsA<VulkanCommandPool>> VulkanCommandPoolExtManual for O {}