FairMQ: Move static and interactive control modes to plugin (2)

This commit is contained in:
Alexey Rybalchenko
2017-09-14 12:42:07 +02:00
committed by Mohammad Al-Turany
parent 10f67e4c72
commit 334b91785b
15 changed files with 246 additions and 138 deletions

View File

@@ -91,9 +91,9 @@ auto PluginServices::ChangeDeviceState(const std::string& controller, const Devi
{
// lock_guard<mutex> lock{fDeviceControllerMutex};
//
// if(!fDeviceController) fDeviceController = controller;
// if (!fDeviceController) fDeviceController = controller;
if(fDeviceController == controller)
if (fDeviceController == controller)
{
fDevice->ChangeState(fkDeviceStateTransitionMap.at(next));
}
@@ -110,11 +110,11 @@ auto PluginServices::TakeDeviceControl(const std::string& controller) -> void
{
lock_guard<mutex> lock{fDeviceControllerMutex};
if(!fDeviceController)
if (!fDeviceController)
{
fDeviceController = controller;
}
else if(fDeviceController == controller)
else if (fDeviceController == controller)
{
// nothing to do
}
@@ -133,15 +133,13 @@ auto PluginServices::ReleaseDeviceControl(const std::string& controller) -> void
{
lock_guard<mutex> lock{fDeviceControllerMutex};
if(fDeviceController == controller)
if (fDeviceController == controller)
{
fDeviceController = boost::none;
}
else
{
throw DeviceControlError{tools::ToString(
"Plugin ", controller, " cannot release control because it has not taken over control."
)};
throw DeviceControlError{tools::ToString("Plugin ", controller, " cannot release control because it has not taken over control.")};
}
}
@@ -159,7 +157,7 @@ auto PluginServices::WaitForReleaseDeviceControl() -> void
{
unique_lock<mutex> lock{fDeviceControllerMutex};
while(GetDeviceController())
while (fDeviceController)
{
fReleaseDeviceControlCondition.wait(lock);
}