Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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 <functional>
10#include <memory>
11#include <thread>
12#include <vector>
13
14#include "flutter/fml/closure.h"
15#include "flutter/fml/status.h"
17
18namespace impeller {
19
20class ContextVK;
21class WaitSetEntry;
22
23using WaitSet = std::vector<std::shared_ptr<WaitSetEntry>>;
24
26 public:
28
29 bool IsValid() const;
30
31 void Terminate();
32
33 /// @brief Invokes the [submit_callback] synchronously and adds the fence to
34 /// the wait set if it succeeds. The [completion_callback] will be
35 /// called when the submitted command completes and the fence is
36 /// signaled.
38 vk::UniqueFence fence,
39 const std::function<fml::Status(vk::Fence)>& submit_callback,
40 fml::closure completion_callback);
41
42 private:
43 friend class ContextVK;
44
45 std::weak_ptr<DeviceHolderVK> device_holder_;
46 std::unique_ptr<std::thread> waiter_thread_;
47 std::mutex wait_set_mutex_;
48 std::condition_variable wait_set_cv_;
49 WaitSet wait_set_;
50 bool terminate_ = false;
51
52 explicit FenceWaiterVK(std::weak_ptr<DeviceHolderVK> device_holder);
53
54 void Main();
55
56 bool Wait();
57 void WaitUntilEmpty();
58
59 FenceWaiterVK(const FenceWaiterVK&) = delete;
60
61 FenceWaiterVK& operator=(const FenceWaiterVK&) = delete;
62};
63
64} // namespace impeller
65
66#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_FENCE_WAITER_VK_H_
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....
std::function< void()> closure
Definition closure.h:14
std::vector< std::shared_ptr< WaitSetEntry > > WaitSet