forked from qt-creator/qt-creator
Docker: Replace mutex+value with SynchronizedValue
Change-Id: Id7ca66be635abbb479602e040889c7ccfa889179 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1385,19 +1385,19 @@ DockerDeviceFactory::DockerDeviceFactory()
|
|||||||
});
|
});
|
||||||
setConstructionFunction([this] {
|
setConstructionFunction([this] {
|
||||||
auto device = DockerDevice::create();
|
auto device = DockerDevice::create();
|
||||||
QMutexLocker lk(&m_deviceListMutex);
|
m_existingDevices.writeLocked()->push_back(device);
|
||||||
m_existingDevices.push_back(device);
|
|
||||||
return device;
|
return device;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DockerDeviceFactory::shutdownExistingDevices()
|
void DockerDeviceFactory::shutdownExistingDevices()
|
||||||
{
|
{
|
||||||
QMutexLocker lk(&m_deviceListMutex);
|
m_existingDevices.read([](const std::vector<std::weak_ptr<DockerDevice>> &devices) {
|
||||||
for (const auto &weakDevice : m_existingDevices) {
|
for (const std::weak_ptr<DockerDevice> &weakDevice : devices) {
|
||||||
if (std::shared_ptr<DockerDevice> device = weakDevice.lock())
|
if (std::shared_ptr<DockerDevice> device = weakDevice.lock())
|
||||||
device->shutdown();
|
device->shutdown();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
expected_str<QPair<Utils::OsType, Utils::OsArch>> DockerDevicePrivate::osTypeAndArch() const
|
expected_str<QPair<Utils::OsType, Utils::OsArch>> DockerDevicePrivate::osTypeAndArch() const
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
#include <projectexplorer/devicesupport/idevice.h>
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||||
|
|
||||||
#include <QMutex>
|
#include <utils/synchronizedvalue.h>
|
||||||
|
|
||||||
namespace Docker::Internal {
|
namespace Docker::Internal {
|
||||||
|
|
||||||
@@ -92,8 +92,7 @@ public:
|
|||||||
void shutdownExistingDevices();
|
void shutdownExistingDevices();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_deviceListMutex;
|
Utils::SynchronizedValue<std::vector<std::weak_ptr<DockerDevice>>> m_existingDevices;
|
||||||
std::vector<std::weak_ptr<DockerDevice>> m_existingDevices;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Docker::Internal
|
} // namespace Docker::Internal
|
||||||
|
Reference in New Issue
Block a user