Disable detection when started in local client mode

master
Adam Honse 5 years ago
parent 8a88573443
commit a2e74eb788

@ -37,6 +37,7 @@ ResourceManager::ResourceManager()
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
| Initialize Detection Variables | | Initialize Detection Variables |
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
detection_enabled = true;
detection_percent = 100; detection_percent = 100;
detection_string = ""; detection_string = "";
detection_is_required = false; detection_is_required = false;
@ -356,38 +357,54 @@ void ResourceManager::Cleanup()
void ResourceManager::DetectDevices() void ResourceManager::DetectDevices()
{ {
/*-------------------------------------------------*\ if(detection_enabled)
| Do nothing is it is already detecting devices |
\*-------------------------------------------------*/
if(detection_is_required.load())
{ {
return; /*-------------------------------------------------*\
} | Do nothing is it is already detecting devices |
\*-------------------------------------------------*/
if(detection_is_required.load())
{
return;
}
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| If there's anything left from the last time, | | If there's anything left from the last time, |
| we shall remove it first | | we shall remove it first |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
detection_percent = 0; detection_percent = 0;
detection_string = ""; detection_string = "";
DetectionProgressChanged(); DetectionProgressChanged();
Cleanup(); Cleanup();
DeviceListChanged(); DeviceListChanged();
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| Start the device detection thread | | Start the device detection thread |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
detection_is_required = true; detection_is_required = true;
DetectDevicesThread = new std::thread(&ResourceManager::DetectDevicesThreadFunction, this); DetectDevicesThread = new std::thread(&ResourceManager::DetectDevicesThreadFunction, this);
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| Release the current thread to allow detection | | Release the current thread to allow detection |
| thread to start | | thread to start |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
std::this_thread::sleep_for(1ms); std::this_thread::sleep_for(1ms);
}
else
{
/*-------------------------------------------------*\
| Signal that detection is complete |
\*-------------------------------------------------*/
detection_percent = 100;
DetectionProgressChanged();
}
}
void ResourceManager::DisableDetection()
{
detection_enabled = false;
} }
void ResourceManager::DetectDevicesThreadFunction() void ResourceManager::DetectDevicesThreadFunction()

@ -101,6 +101,8 @@ public:
void DetectDevices(); void DetectDevices();
void DisableDetection();
void StopDeviceDetection(); void StopDeviceDetection();
void WaitForDeviceDetection(); void WaitForDeviceDetection();
@ -111,6 +113,11 @@ private:
static std::unique_ptr<ResourceManager> instance; static std::unique_ptr<ResourceManager> instance;
/*-------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------*\
| Detection enabled flag |
\*-------------------------------------------------------------------------------------*/
bool detection_enabled;
/*-------------------------------------------------------------------------------------*\
| Profile Manager | | Profile Manager |
\*-------------------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------------------*/
ProfileManager* profile_manager; ProfileManager* profile_manager;

@ -172,6 +172,10 @@ int main(int argc, char* argv[])
{ {
ResourceManager::get()->DetectDevices(); ResourceManager::get()->DetectDevices();
} }
else
{
ResourceManager::get()->DisableDetection();
}
} }
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\

Loading…
Cancel
Save