5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RESOURCE_MANAGER_VK_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_RESOURCE_MANAGER_VK_H_
8#include <condition_variable>
38 :
public std::enable_shared_from_this<ResourceManagerVK> {
52 static std::shared_ptr<ResourceManagerVK>
Create();
74 using Reclaimables = std::vector<std::unique_ptr<ResourceVK>>;
77 std::mutex reclaimables_mutex_;
78 std::condition_variable reclaimables_cv_;
79 Reclaimables reclaimables_;
80 bool should_exit_ =
false;
111template <
class ResourceType_>
142template <
class ResourceType_>
153 : resource_manager_(
std::move(resource_manager)) {}
164 : resource_manager_(
std::move(resource_manager)),
173 FML_CHECK(resource_) <<
"UniqueResourceVKT was reclaimed.";
175 return resource_.get()->Get();
183 resource_ = std::make_unique<ResourceVKT<ResourceType>>(std::move(other));
194 if (
auto manager = resource_manager_.lock()) {
195 manager->Reclaim(std::move(resource_));
201 std::weak_ptr<ResourceManagerVK> resource_manager_;
202 std::unique_ptr<ResourceVKT<ResourceType>> resource_;
static SkString resource(SkPDFResourceType type, int index)
A resource manager controls how resources are allocated and reclaimed.
static std::shared_ptr< ResourceManagerVK > Create()
Creates a shared resource manager (a dedicated thread).
void Reclaim(std::unique_ptr< ResourceVK > resource)
Mark a resource as being reclaimable.
~ResourceManagerVK()
Destroys the resource manager.
An internal type that is used to move a resource reference.
ResourceType_ ResourceType
ResourceVKT(ResourceType &&resource)
Construct a resource from a move-constructible resource.
const ResourceType * Get() const
Returns a pointer to the resource.
A resource that may be reclaimed by a |ResourceManagerVK|.
virtual ~ResourceVK()=default
A unique handle to a resource which will be reclaimed by the specified resource manager.
void Reset()
Reclaims the existing resource, if any.
const ResourceType * operator->() const
Returns a pointer to the resource.
void Swap(ResourceType &&other)
Reclaims the existing resource, if any, and replaces it.
UniqueResourceVKT(std::weak_ptr< ResourceManagerVK > resource_manager)
Construct a unique resource handle belonging to a manager.
UniqueResourceVKT(std::weak_ptr< ResourceManagerVK > resource_manager, ResourceType &&resource)
Construct a unique resource handle belonging to a manager.
ResourceType_ ResourceType
#define FML_CHECK(condition)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager