Disable detection when started in local client mode
This commit is contained in:
parent
8a88573443
commit
a2e74eb788
3 changed files with 57 additions and 29 deletions
|
|
@ -37,6 +37,7 @@ ResourceManager::ResourceManager()
|
|||
/*-------------------------------------------------------------------------*\
|
||||
| Initialize Detection Variables |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
detection_enabled = true;
|
||||
detection_percent = 100;
|
||||
detection_string = "";
|
||||
detection_is_required = false;
|
||||
|
|
@ -356,38 +357,54 @@ void ResourceManager::Cleanup()
|
|||
|
||||
void ResourceManager::DetectDevices()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Do nothing is it is already detecting devices |
|
||||
\*-------------------------------------------------*/
|
||||
if(detection_is_required.load())
|
||||
if(detection_enabled)
|
||||
{
|
||||
return;
|
||||
/*-------------------------------------------------*\
|
||||
| Do nothing is it is already detecting devices |
|
||||
\*-------------------------------------------------*/
|
||||
if(detection_is_required.load())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If there's anything left from the last time, |
|
||||
| we shall remove it first |
|
||||
\*-------------------------------------------------*/
|
||||
detection_percent = 0;
|
||||
detection_string = "";
|
||||
|
||||
DetectionProgressChanged();
|
||||
|
||||
Cleanup();
|
||||
|
||||
DeviceListChanged();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Start the device detection thread |
|
||||
\*-------------------------------------------------*/
|
||||
detection_is_required = true;
|
||||
DetectDevicesThread = new std::thread(&ResourceManager::DetectDevicesThreadFunction, this);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Release the current thread to allow detection |
|
||||
| thread to start |
|
||||
\*-------------------------------------------------*/
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Signal that detection is complete |
|
||||
\*-------------------------------------------------*/
|
||||
detection_percent = 100;
|
||||
DetectionProgressChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If there's anything left from the last time, |
|
||||
| we shall remove it first |
|
||||
\*-------------------------------------------------*/
|
||||
detection_percent = 0;
|
||||
detection_string = "";
|
||||
|
||||
DetectionProgressChanged();
|
||||
|
||||
Cleanup();
|
||||
|
||||
DeviceListChanged();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Start the device detection thread |
|
||||
\*-------------------------------------------------*/
|
||||
detection_is_required = true;
|
||||
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::DisableDetection()
|
||||
{
|
||||
detection_enabled = false;
|
||||
}
|
||||
|
||||
void ResourceManager::DetectDevicesThreadFunction()
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ public:
|
|||
|
||||
void DetectDevices();
|
||||
|
||||
void DisableDetection();
|
||||
|
||||
void StopDeviceDetection();
|
||||
|
||||
void WaitForDeviceDetection();
|
||||
|
|
@ -110,6 +112,11 @@ private:
|
|||
|
||||
static std::unique_ptr<ResourceManager> instance;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detection enabled flag |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
bool detection_enabled;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Profile Manager |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
|
|
|
|||
4
main.cpp
4
main.cpp
|
|
@ -172,6 +172,10 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
ResourceManager::get()->DetectDevices();
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceManager::get()->DisableDetection();
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue