Flutter Impeller
impeller::FenceWaiterVK Class Reference

#include <fence_waiter_vk.h>

Public Member Functions

 ~FenceWaiterVK ()
 
bool IsValid () const
 
void Terminate ()
 
fml::Status AddFence (vk::UniqueFence fence, const std::function< fml::Status(vk::Fence)> &submit_callback, fml::closure completion_callback)
 Invokes the [submit_callback] synchronously and adds the fence to the wait set if it succeeds. The [completion_callback] will be called when the submitted command completes and the fence is signaled. More...
 

Friends

class ContextVK
 

Detailed Description

Definition at line 25 of file fence_waiter_vk.h.

Constructor & Destructor Documentation

◆ ~FenceWaiterVK()

impeller::FenceWaiterVK::~FenceWaiterVK ( )

Definition at line 59 of file fence_waiter_vk.cc.

59  {
60  Terminate();
61 }

References Terminate().

Member Function Documentation

◆ AddFence()

fml::Status impeller::FenceWaiterVK::AddFence ( vk::UniqueFence  fence,
const std::function< fml::Status(vk::Fence)> &  submit_callback,
fml::closure  completion_callback 
)

Invokes the [submit_callback] synchronously and adds the fence to the wait set if it succeeds. The [completion_callback] will be called when the submitted command completes and the fence is signaled.

Definition at line 63 of file fence_waiter_vk.cc.

66  {
67  if (!fence || !submit_callback || !completion_callback) {
68  return fml::Status(fml::StatusCode::kInvalidArgument, "Invalid arguments");
69  }
70  {
71  // Maintain the invariant that terminate_ is accessed only under the lock.
72  std::scoped_lock lock(wait_set_mutex_);
73  if (terminate_) {
74  return fml::Status(fml::StatusCode::kCancelled,
75  "Fence waiter is terminated");
76  }
77  auto submit_status = submit_callback(fence.get());
78  if (!submit_status.ok()) {
79  return submit_status;
80  }
81  wait_set_.emplace_back(
82  WaitSetEntry::Create(std::move(fence), std::move(completion_callback)));
83  }
84  wait_set_cv_.notify_one();
85  return fml::Status();
86 }
static std::shared_ptr< WaitSetEntry > Create(vk::UniqueFence p_fence, fml::closure p_callback)

References impeller::WaitSetEntry::Create().

◆ IsValid()

bool impeller::FenceWaiterVK::IsValid ( ) const

◆ Terminate()

void impeller::FenceWaiterVK::Terminate ( )

Definition at line 213 of file fence_waiter_vk.cc.

213  {
214  {
215  std::scoped_lock lock(wait_set_mutex_);
216  if (terminate_) {
217  return;
218  }
219  terminate_ = true;
220  }
221  wait_set_cv_.notify_one();
222  waiter_thread_->join();
223 }

Referenced by ~FenceWaiterVK().

Friends And Related Function Documentation

◆ ContextVK

friend class ContextVK
friend

Definition at line 43 of file fence_waiter_vk.h.


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