mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
DDS plugin: refactor for better readability
This commit is contained in:
parent
96348b8462
commit
32764e1b12
|
@ -74,15 +74,22 @@ DDS::DDS(const string& name,
|
||||||
// subscribe to device state changes, pushing new state changes into the event queue
|
// subscribe to device state changes, pushing new state changes into the event queue
|
||||||
SubscribeToDeviceStateChange([&](DeviceState newState) {
|
SubscribeToDeviceStateChange([&](DeviceState newState) {
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case DeviceState::Bound:
|
case DeviceState::Bound: {
|
||||||
// Receive addresses of connecting channels from DDS
|
// Receive addresses of connecting channels from DDS
|
||||||
// and propagate addresses of bound channels to DDS.
|
// and propagate addresses of bound channels to DDS.
|
||||||
FillChannelContainers();
|
FillChannelContainers();
|
||||||
|
|
||||||
|
// allow updates from key value after channel containers are filled
|
||||||
|
{
|
||||||
|
lock_guard<mutex> lk(fUpdateMutex);
|
||||||
|
fUpdatesAllowed = true;
|
||||||
|
}
|
||||||
|
fUpdateCondition.notify_one();
|
||||||
|
|
||||||
// publish bound addresses via DDS at keys corresponding to the channel
|
// publish bound addresses via DDS at keys corresponding to the channel
|
||||||
// prefixes, e.g. 'data' in data[i]
|
// prefixes, e.g. 'data' in data[i]
|
||||||
PublishBoundChannels();
|
PublishBoundChannels();
|
||||||
break;
|
} break;
|
||||||
case DeviceState::ResettingDevice: {
|
case DeviceState::ResettingDevice: {
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lk(fUpdateMutex);
|
lock_guard<mutex> lk(fUpdateMutex);
|
||||||
|
@ -90,9 +97,8 @@ DDS::DDS(const string& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
EmptyChannelContainers();
|
EmptyChannelContainers();
|
||||||
break;
|
} break;
|
||||||
}
|
case DeviceState::Exiting: {
|
||||||
case DeviceState::Exiting:
|
|
||||||
if (!fControllerThread.joinable()) {
|
if (!fControllerThread.joinable()) {
|
||||||
fControllerThread = thread(&DDS::WaitForExitingAck, this);
|
fControllerThread = thread(&DDS::WaitForExitingAck, this);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +106,7 @@ DDS::DDS(const string& name,
|
||||||
fDeviceTerminationRequested = true;
|
fDeviceTerminationRequested = true;
|
||||||
UnsubscribeFromDeviceStateChange();
|
UnsubscribeFromDeviceStateChange();
|
||||||
ReleaseDeviceControl();
|
ReleaseDeviceControl();
|
||||||
break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -213,11 +219,6 @@ auto DDS::FillChannelContainers() -> void
|
||||||
LOG(debug) << "dds-i-n: adding " << chanName << " -> i: " << i << " n: " << n;
|
LOG(debug) << "dds-i-n: adding " << chanName << " -> i: " << i << " n: " << n;
|
||||||
fIofN.insert(make_pair(chanName, IofN(i, n)));
|
fIofN.insert(make_pair(chanName, IofN(i, n)));
|
||||||
}
|
}
|
||||||
{
|
|
||||||
lock_guard<mutex> lk(fUpdateMutex);
|
|
||||||
fUpdatesAllowed = true;
|
|
||||||
}
|
|
||||||
fUpdateCondition.notify_one();
|
|
||||||
} catch (const exception& e) {
|
} catch (const exception& e) {
|
||||||
LOG(error) << "Error filling channel containers: " << e.what();
|
LOG(error) << "Error filling channel containers: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user