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:
@@ -15,32 +15,38 @@
|
||||
#include <nanomsg/nn.h>
|
||||
|
||||
#include "FairMQPollerNN.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQPollerNN::FairMQPollerNN(const vector<FairMQSocket*>& inputs)
|
||||
FairMQPollerNN::FairMQPollerNN(const vector<FairMQChannel>& channels)
|
||||
: items()
|
||||
, fNumItems()
|
||||
{
|
||||
fNumItems = inputs.size();
|
||||
fNumItems = channels.size();
|
||||
items = new nn_pollfd[fNumItems];
|
||||
|
||||
for (int i = 0; i < fNumItems; i++)
|
||||
for (int i = 0; i < fNumItems; ++i)
|
||||
{
|
||||
items[i].fd = inputs.at(i)->GetSocket(1);
|
||||
items[i].fd = channels.at(i).fSocket->GetSocket(1);
|
||||
items[i].events = NN_POLLIN;
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQPollerNN::Poll(int timeout)
|
||||
{
|
||||
nn_poll(items, fNumItems, timeout);
|
||||
if (nn_poll(items, fNumItems, timeout) < 0)
|
||||
{
|
||||
LOG(ERROR) << "polling failed, reason: " << nn_strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
bool FairMQPollerNN::CheckInput(int index)
|
||||
{
|
||||
if (items[index].revents & NN_POLLIN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -48,7 +54,9 @@ bool FairMQPollerNN::CheckInput(int index)
|
||||
bool FairMQPollerNN::CheckOutput(int index)
|
||||
{
|
||||
if (items[index].revents & NN_POLLOUT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -56,5 +64,7 @@ bool FairMQPollerNN::CheckOutput(int index)
|
||||
FairMQPollerNN::~FairMQPollerNN()
|
||||
{
|
||||
if (items != NULL)
|
||||
{
|
||||
delete[] items;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user