From b0b271d1f4152791c388b929c33642dc4d0d97ab Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Thu, 21 Nov 2019 10:54:14 +0100 Subject: [PATCH] DDS plugin: remove static mode --- fairmq/plugins/DDS/DDS.cxx | 50 ++++---------------------------------- fairmq/plugins/DDS/DDS.h | 6 ----- 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/fairmq/plugins/DDS/DDS.cxx b/fairmq/plugins/DDS/DDS.cxx index 6435acd7..385e5bf9 100644 --- a/fairmq/plugins/DDS/DDS.cxx +++ b/fairmq/plugins/DDS/DDS.cxx @@ -37,16 +37,6 @@ DDS::DDS(const string& name, const string& homepage, PluginServices* pluginServices) : Plugin(name, version, maintainer, homepage, pluginServices) - , fTransitions({"INIT DEVICE", - "COMPLETE INIT", - "BIND", - "CONNECT", - "INIT TASK", - "RUN", - "STOP", - "RESET TASK", - "RESET DEVICE", - "END"}) , fCurrentState(DeviceState::Idle) , fLastState(DeviceState::Idle) , fDeviceTerminationRequested(false) @@ -71,15 +61,13 @@ DDS::DDS(const string& name, } auto control = GetProperty("control"); - bool staticMode(false); if (control == "static") { - LOG(debug) << "Running DDS controller: static"; - staticMode = true; + LOG(error) << "DDS Plugin: static mode is not supported"; + throw invalid_argument("DDS Plugin: static mode is not supported"); } else if (control == "dynamic" || control == "external" || control == "interactive") { LOG(debug) << "Running DDS controller: external"; } else { - LOG(error) << "Unrecognized control mode '" << control << "' requested. " << "Ignoring and falling back to static control mode."; - staticMode = true; + LOG(error) << "Unrecognized control mode '" << control << "' requested. " << "Ignoring and starting in external control mode."; } SubscribeForCustomCommands(); @@ -108,11 +96,7 @@ DDS::DDS(const string& name, } case DeviceState::Exiting: fWorkGuard.reset(); - { - unique_lock lock(fStopMutex); - fDeviceTerminationRequested = true; - } - fStopCondition.notify_one(); + fDeviceTerminationRequested = true; UnsubscribeFromDeviceStateChange(); ReleaseDeviceControl(); break; @@ -133,11 +117,7 @@ DDS::DDS(const string& name, } }); - if (staticMode) { - fControllerThread = thread(&DDS::StaticControl, this); - } else { - StartWorkerThread(); - } + StartWorkerThread(); fDDS.Start(); } catch (PluginServices::DeviceControlError& e) { @@ -169,26 +149,6 @@ auto DDS::WaitForExitingAck() -> void [this]() { return fExitingAckedByLastExternalController; }); } -auto DDS::StaticControl() -> void -{ - try { - TransitionDeviceStateTo(DeviceState::Running); - - // wait until stop signal - unique_lock lock(fStopMutex); - while (!fDeviceTerminationRequested) { - fStopCondition.wait_for(lock, chrono::seconds(1)); - } - LOG(debug) << "Stopping DDS plugin static controller"; - } catch (DeviceErrorState&) { - ReleaseDeviceControl(); - } catch (exception& e) { - ReleaseDeviceControl(); - LOG(error) << "Error: " << e.what() << "\n"; - return; - } -} - auto DDS::FillChannelContainers() -> void { try { diff --git a/fairmq/plugins/DDS/DDS.h b/fairmq/plugins/DDS/DDS.h index 242e715a..cd1c3228 100644 --- a/fairmq/plugins/DDS/DDS.h +++ b/fairmq/plugins/DDS/DDS.h @@ -133,7 +133,6 @@ class DDS : public Plugin ~DDS(); private: - auto StaticControl() -> void; auto WaitForExitingAck() -> void; auto StartWorkerThread() -> void; @@ -154,11 +153,6 @@ class DDS : public Plugin std::unordered_map fI; std::unordered_map fIofN; - std::mutex fStopMutex; - std::condition_variable fStopCondition; - - const std::set fTransitions; - std::thread fControllerThread; DeviceState fCurrentState, fLastState;