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:
Alexey Rybalchenko
2015-04-29 13:25:42 +02:00
parent a2ebbbe450
commit 7fda980710
54 changed files with 1674 additions and 1573 deletions

View File

@@ -31,15 +31,13 @@ void FairMQExampleServer::CustomCleanup(void *data, void *hint)
void FairMQExampleServer::Run()
{
// boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
while (fState == RUNNING)
while (GetCurrentState() == RUNNING)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
FairMQMessage* request = fTransportFactory->CreateMessage();
fPayloadInputs->at(0)->Receive(request);
fChannels["data"].at(0).Receive(request);
LOG(INFO) << "Received request from client: \"" << string(static_cast<char*>(request->GetData()), request->GetSize()) << "\"";
@@ -51,17 +49,8 @@ void FairMQExampleServer::Run()
FairMQMessage* reply = fTransportFactory->CreateMessage(const_cast<char*>(text->c_str()), text->length(), CustomCleanup, text);
fPayloadInputs->at(0)->Send(reply);
fChannels["data"].at(0).Send(reply);
}
// rateLogger.interrupt();
// rateLogger.join();
FairMQDevice::Shutdown();
boost::lock_guard<boost::mutex> lock(fRunningMutex);
fRunningFinished = true;
fRunningCondition.notify_one();
}
FairMQExampleServer::~FairMQExampleServer()