Flutter Impeller
fence_waiter_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FENCE_WAITER_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FENCE_WAITER_VK_H_
7 
8 #include <condition_variable>
9 #include <memory>
10 #include <thread>
11 #include <vector>
12 
13 #include "flutter/fml/closure.h"
14 #include "flutter/fml/macros.h"
15 #include "impeller/base/thread.h"
19 
20 namespace impeller {
21 
22 class ContextVK;
23 class WaitSetEntry;
24 
25 using WaitSet = std::vector<std::shared_ptr<WaitSetEntry>>;
26 
28  public:
30 
31  bool IsValid() const;
32 
33  void Terminate();
34 
35  bool AddFence(vk::UniqueFence fence, const fml::closure& callback);
36 
37  private:
38  friend class ContextVK;
39 
40  std::weak_ptr<DeviceHolderVK> device_holder_;
41  std::unique_ptr<std::thread> waiter_thread_;
42  std::mutex wait_set_mutex_;
43  std::condition_variable wait_set_cv_;
44  WaitSet wait_set_;
45  bool terminate_ = false;
46 
47  explicit FenceWaiterVK(std::weak_ptr<DeviceHolderVK> device_holder);
48 
49  void Main();
50 
51  bool Wait();
52  void WaitUntilEmpty();
53 
54  FenceWaiterVK(const FenceWaiterVK&) = delete;
55 
56  FenceWaiterVK& operator=(const FenceWaiterVK&) = delete;
57 };
58 
59 } // namespace impeller
60 
61 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FENCE_WAITER_VK_H_
impeller::WaitSet
std::vector< std::shared_ptr< WaitSetEntry > > WaitSet
Definition: fence_waiter_vk.h:25
shared_object_vk.h
impeller::FenceWaiterVK::AddFence
bool AddFence(vk::UniqueFence fence, const fml::closure &callback)
Definition: fence_waiter_vk.cc:65
vk.h
impeller::compiler::Main
bool Main(const fml::CommandLine &command_line)
Definition: impellerc_main.cc:233
device_holder_vk.h
impeller::FenceWaiterVK::IsValid
bool IsValid() const
impeller::ContextVK
Definition: context_vk.h:42
impeller::FenceWaiterVK::Terminate
void Terminate()
Definition: fence_waiter_vk.cc:207
impeller::FenceWaiterVK::~FenceWaiterVK
~FenceWaiterVK()
Definition: fence_waiter_vk.cc:60
impeller::FenceWaiterVK
Definition: fence_waiter_vk.h:27
thread.h
impeller
Definition: aiks_blur_unittests.cc:20