Wait on asynchronous device detection before performing CLI operations that require device list

This commit is contained in:
Adam Honse 2020-08-07 23:01:20 -05:00
parent 9c4e73bbed
commit 634ec9f488
2 changed files with 26 additions and 4 deletions

View file

@ -3,6 +3,7 @@
std::unique_ptr<ResourceManager> ResourceManager::instance;
using namespace std::chrono_literals;
ResourceManager *ResourceManager::get()
{
@ -22,15 +23,17 @@ ResourceManager::ResourceManager()
ResourceManager::~ResourceManager()
{
for(i2c_smbus_interface* bus : busses)
{
delete bus;
}
ResourceManager::get()->WaitForDeviceDetection();
for(RGBController* rgb_controller : rgb_controllers)
{
delete rgb_controller;
}
for(i2c_smbus_interface* bus : busses)
{
//delete bus;
}
}
void ResourceManager::RegisterI2CBus(i2c_smbus_interface *bus)
@ -108,6 +111,12 @@ void ResourceManager::DetectDevices()
| Start the device detection thread |
\*-------------------------------------------------*/
DetectDevicesThread = new std::thread(&ResourceManager::DetectDevicesThreadFunction, this);
/*-------------------------------------------------*\
| Release the current thread to allow detection |
| thread to start |
\*-------------------------------------------------*/
std::this_thread::sleep_for(1ms);
}
void ResourceManager::DetectDevicesThreadFunction()