MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / getPollingBasedDeviceList

Function getPollingBasedDeviceList

plugins/usb/usb-helpers.cpp:165–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165static std::vector<USBDeviceInfo> getPollingBasedDeviceList()
166{
167 // Polling can be very expensive
168 // Perform this operation at most once every 10 seconds
169 static const int timeout = 10;
170 static std::vector<USBDeviceInfo> deviceList = {};
171 static std::chrono::high_resolution_clock::time_point lastUpdate = {};
172
173 std::lock_guard<std::mutex> lock(mutex);
174 auto now = std::chrono::high_resolution_clock::now();
175 if (std::chrono::duration_cast<std::chrono::seconds>(now - lastUpdate)
176 .count() >= timeout) {
177 deviceList = pollUSBDevices();
178 lastUpdate = now;
179 }
180
181 return deviceList;
182}
183
184std::vector<USBDeviceInfo> GetUSBDevices()
185{

Callers 1

GetUSBDevicesFunction · 0.85

Calls 3

nowClass · 0.85
pollUSBDevicesFunction · 0.85
countMethod · 0.80

Tested by

no test coverage detected