mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Update FairMQStateMachine & introduce FairMQChannels
Organize sockets as a map of vectors of FairMQChannels. Update FairMQStateMachine by removing SETTINGINPUT, SETTINGOUTPUT, BIND and CONNECT states and by adding INITIALIZING_TASK, RESETTING_TASK and RESETTING_DEVICE states. Run states functions in their own thread.
This commit is contained in:
@@ -28,44 +28,22 @@ FairMQSplitter::~FairMQSplitter()
|
||||
|
||||
void FairMQSplitter::Run()
|
||||
{
|
||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
|
||||
int received = 0;
|
||||
int direction = 0;
|
||||
|
||||
while (fState == RUNNING)
|
||||
while (GetCurrentState() == RUNNING)
|
||||
{
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||
|
||||
received = fPayloadInputs->at(0)->Receive(msg);
|
||||
|
||||
if (received > 0)
|
||||
if (fChannels["data-in"].at(0).Receive(msg) > 0)
|
||||
{
|
||||
fPayloadOutputs->at(direction)->Send(msg);
|
||||
fChannels["data-out"].at(direction).Send(msg);
|
||||
direction++;
|
||||
if (direction >= fNumOutputs)
|
||||
if (direction >= fChannels["data-out"].size())
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
received = 0;
|
||||
}
|
||||
|
||||
delete msg;
|
||||
}
|
||||
|
||||
try {
|
||||
rateLogger.interrupt();
|
||||
rateLogger.join();
|
||||
} catch(boost::thread_resource_error& e) {
|
||||
LOG(ERROR) << e.what();
|
||||
}
|
||||
|
||||
FairMQDevice::Shutdown();
|
||||
|
||||
// notify parent thread about end of processing.
|
||||
boost::lock_guard<boost::mutex> lock(fRunningMutex);
|
||||
fRunningFinished = true;
|
||||
fRunningCondition.notify_one();
|
||||
}
|
||||
|
Reference in New Issue
Block a user