ngscopeclient v0.2
Loading...
Searching...
No Matches
QueueWrapper.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
37#ifndef QueueWrapper_h
38#define QueueWrapper_h
39
40class QueueLock;
41
48{
49public:
50 QueueWrapper(std::shared_ptr<vk::raii::Device> device, size_t family, size_t index);
52
54 void AddName(std::string name)
55 {
56 const std::lock_guard<std::recursive_mutex> lock(m_mutex);
57 m_names.emplace(name);
58 UpdateName();
59 }
60
62 void RemoveName(std::string name)
63 {
64 const std::lock_guard<std::recursive_mutex> lock(m_mutex);
65 m_names.erase(name);
66 UpdateName();
67 }
68
74 const std::string GetName()
75 {
76 std::string ret;
77 {
78 std::lock_guard<std::recursive_mutex> lock(m_mutex);
79 ret = m_name;
80 }
81 return ret;
82 }
83
85 std::recursive_mutex& GetMutex()
86 { return m_mutex; }
87
88 std::unique_ptr<vk::raii::Queue>& GetQueue()
89 { return m_queue; }
90
91 std::shared_ptr<vk::raii::Device>& GetDevice()
92 { return m_device; }
93
94public:
95 //non-copyable
96 QueueWrapper(QueueWrapper const&) = delete;
97 QueueWrapper& operator=(QueueWrapper const&) = delete;
98
99public:
100
102 const size_t m_family;
103
105 const size_t m_index;
106
107protected:
108
109 void UpdateName();
110
111 friend QueueLock;
112
114 std::recursive_mutex m_mutex;
115
117 std::string m_name;
118
120 std::set<std::string> m_names;
121
123 std::shared_ptr<vk::raii::Device> m_device;
124
126 std::unique_ptr<vk::raii::Queue> m_queue;
127};
128
129#endif
Definition AcceleratorBuffer.h:204
Obtains exclusive access to a Vulkan Queue for the duration of its existence, similar to a std::lock_...
Definition QueueManager.h:58
Mutexed wrapper around a Vulkan queue.
Definition QueueWrapper.h:48
const std::string GetName()
Get the name of this queue.
Definition QueueWrapper.h:74
std::recursive_mutex & GetMutex()
Get the mutex for the queue.
Definition QueueWrapper.h:85
std::shared_ptr< vk::raii::Device > m_device
The Vulkan device this queue submits to.
Definition QueueWrapper.h:123
std::string m_name
Debug name of the queue.
Definition QueueWrapper.h:117
void AddName(std::string name)
Append a name to the queue, used for debugging.
Definition QueueWrapper.h:54
void UpdateName()
Update the debug name after an entry has been added or removed.
Definition QueueWrapper.cpp:62
const size_t m_index
Index of this queue within the queue family.
Definition QueueWrapper.h:105
const size_t m_family
Family of the queue.
Definition QueueWrapper.h:102
void RemoveName(std::string name)
Remove a name to the queue, used for debugging.
Definition QueueWrapper.h:62
std::set< std::string > m_names
Set of names.
Definition QueueWrapper.h:120
std::unique_ptr< vk::raii::Queue > m_queue
The underlying Vulkan handle.
Definition QueueWrapper.h:126
std::recursive_mutex m_mutex
The mutex controlling access to the queue.
Definition QueueWrapper.h:114