Flutter Engine
vulkan::VulkanHandle< T > Class Template Reference

#include <vulkan_handle.h>

Public Types

using Handle = T
 
using Disposer = std::function< void(Handle)>
 

Public Member Functions

 VulkanHandle ()
 
 VulkanHandle (Handle handle, const Disposer &disposer=nullptr)
 
 VulkanHandle (VulkanHandle &&other)
 
 ~VulkanHandle ()
 
VulkanHandleoperator= (VulkanHandle &&other)
 
 operator bool () const
 
 operator Handle () const
 
void ReleaseOwnership ()
 
void Reset ()
 

Detailed Description

template<class T>
class vulkan::VulkanHandle< T >

Definition at line 17 of file vulkan_handle.h.

Member Typedef Documentation

◆ Disposer

template<class T>
using vulkan::VulkanHandle< T >::Disposer = std::function<void(Handle)>

Definition at line 20 of file vulkan_handle.h.

◆ Handle

template<class T>
using vulkan::VulkanHandle< T >::Handle = T

Definition at line 19 of file vulkan_handle.h.

Constructor & Destructor Documentation

◆ VulkanHandle() [1/3]

template<class T>
vulkan::VulkanHandle< T >::VulkanHandle ( )
inline

Definition at line 22 of file vulkan_handle.h.

22 : handle_(VK_NULL_HANDLE) {}

◆ VulkanHandle() [2/3]

template<class T>
vulkan::VulkanHandle< T >::VulkanHandle ( Handle  handle,
const Disposer disposer = nullptr 
)
inline

Definition at line 24 of file vulkan_handle.h.

25  : handle_(handle), disposer_(disposer) {}

◆ VulkanHandle() [3/3]

template<class T>
vulkan::VulkanHandle< T >::VulkanHandle ( VulkanHandle< T > &&  other)
inline

Definition at line 27 of file vulkan_handle.h.

28  : handle_(other.handle_), disposer_(other.disposer_) {
29  other.handle_ = VK_NULL_HANDLE;
30  other.disposer_ = nullptr;
31  }

◆ ~VulkanHandle()

template<class T>
vulkan::VulkanHandle< T >::~VulkanHandle ( )
inline

Definition at line 33 of file vulkan_handle.h.

33 { DisposeIfNecessary(); }

Member Function Documentation

◆ operator bool()

template<class T>
vulkan::VulkanHandle< T >::operator bool ( ) const
inline

Definition at line 49 of file vulkan_handle.h.

49 { return handle_ != VK_NULL_HANDLE; }

◆ operator Handle()

template<class T>
vulkan::VulkanHandle< T >::operator Handle ( ) const
inline

Definition at line 51 of file vulkan_handle.h.

51 { return handle_; }

◆ operator=()

template<class T>
VulkanHandle& vulkan::VulkanHandle< T >::operator= ( VulkanHandle< T > &&  other)
inline

Definition at line 35 of file vulkan_handle.h.

35  {
36  if (handle_ != other.handle_) {
37  DisposeIfNecessary();
38  }
39 
40  handle_ = other.handle_;
41  disposer_ = other.disposer_;
42 
43  other.handle_ = VK_NULL_HANDLE;
44  other.disposer_ = nullptr;
45 
46  return *this;
47  }

◆ ReleaseOwnership()

template<class T>
void vulkan::VulkanHandle< T >::ReleaseOwnership ( )
inline

Relinquish responsibility of collecting the underlying handle when this object is collected. It is the responsibility of the caller to ensure that the lifetime of the handle extends past the lifetime of this object.

Definition at line 56 of file vulkan_handle.h.

Referenced by vulkan::VulkanDevice::ReleaseDeviceOwnership(), and vulkan::VulkanApplication::ReleaseInstanceOwnership().

56 { disposer_ = nullptr; }

◆ Reset()

template<class T>
void vulkan::VulkanHandle< T >::Reset ( )
inline

Definition at line 58 of file vulkan_handle.h.

Referenced by flutter_runner::VulkanSurface::SignalWritesFinished().

58 { DisposeIfNecessary(); }

The documentation for this class was generated from the following file: