mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
Update multi-part features (nanomsg) and various fixes
- Implement nanomsg multipart with MessagePack. - Use the MessagePack from FairSoft and handle not found case. - Update splitter, merger and proxy devices to handle multi-part. - Let FairMQParts.At() return pointer reference (can be used for moving). - Add missing const specifier in the message interface. - Add transmit kernel size setting to channels (ZMQ_SNDBUF). - Remove FairMQBuffer device. - Remove old multi-part methods from Tutorial3 example (to be replaced with Parts API). - Make callback mandatory for newMsg(data, size, callback). - Add missing <vector> include in FairMQSocket.
This commit is contained in:
@@ -35,10 +35,9 @@ FairMQBenchmarkSampler::~FairMQBenchmarkSampler()
|
||||
|
||||
void FairMQBenchmarkSampler::Run()
|
||||
{
|
||||
void* buffer = malloc(fMsgSize);
|
||||
int numSentMsgs = 0;
|
||||
|
||||
unique_ptr<FairMQMessage> baseMsg(fTransportFactory->CreateMessage(buffer, fMsgSize));
|
||||
unique_ptr<FairMQMessage> baseMsg(fTransportFactory->CreateMessage(fMsgSize));
|
||||
|
||||
// store the channel reference to avoid traversing the map on every loop iteration
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
|
@@ -1,46 +0,0 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQBuffer.cxx
|
||||
*
|
||||
* @since 2012-10-25
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "FairMQBuffer.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
FairMQBuffer::FairMQBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQBuffer::Run()
|
||||
{
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
|
||||
if (dataInChannel.Receive(msg) > 0)
|
||||
{
|
||||
dataOutChannel.Send(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FairMQBuffer::~FairMQBuffer()
|
||||
{
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* FairMQBuffer.h
|
||||
*
|
||||
* @since 2012-10-25
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#ifndef FAIRMQBUFFER_H_
|
||||
#define FAIRMQBUFFER_H_
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
|
||||
class FairMQBuffer : public FairMQDevice
|
||||
{
|
||||
public:
|
||||
FairMQBuffer();
|
||||
virtual ~FairMQBuffer();
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
#endif /* FAIRMQBUFFER_H_ */
|
@@ -29,22 +29,12 @@ FairMQMerger::~FairMQMerger()
|
||||
|
||||
void FairMQMerger::Run()
|
||||
{
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
auto& dataInChannelRef = fChannels.at("data-in");
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
int numInputs = dataInChannelRef.size();
|
||||
std::vector<FairMQChannel*> dataInChannels(numInputs);
|
||||
for (int i = 0; i < numInputs; ++i)
|
||||
{
|
||||
dataInChannels.at(i) = &(dataInChannelRef.at(i));
|
||||
}
|
||||
int numInputs = fChannels.at("data-in").size();
|
||||
|
||||
std::unique_ptr<FairMQPoller> poller(fTransportFactory->CreatePoller(dataInChannelRef));
|
||||
std::unique_ptr<FairMQPoller> poller(fTransportFactory->CreatePoller(fChannels.at("data-in")));
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
|
||||
poller->Poll(100);
|
||||
|
||||
// Loop over the data input channels.
|
||||
@@ -53,19 +43,19 @@ void FairMQMerger::Run()
|
||||
// Check if the channel has data ready to be received.
|
||||
if (poller->CheckInput(i))
|
||||
{
|
||||
// Try receiving the data.
|
||||
if (dataInChannels[i]->Receive(msg) >= 0)
|
||||
FairMQParts parts;
|
||||
|
||||
if (Receive(parts, "data-in", i) >= 0)
|
||||
{
|
||||
// If data was received, send it to output.
|
||||
if (dataOutChannel.Send(msg) < 0)
|
||||
if (Send(parts, "data-out") < 0)
|
||||
{
|
||||
LOG(DEBUG) << "Blocking send interrupted by a command";
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(DEBUG) << "Blocking receive interrupted by a command";
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -28,17 +28,22 @@ FairMQProxy::~FairMQProxy()
|
||||
|
||||
void FairMQProxy::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
if (dataInChannel.Receive(msg) > 0)
|
||||
FairMQParts parts;
|
||||
|
||||
if (Receive(parts, "data-in") >= 0)
|
||||
{
|
||||
dataOutChannel.Send(msg);
|
||||
if (Send(parts, "data-out") < 0)
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,30 +28,32 @@ FairMQSplitter::~FairMQSplitter()
|
||||
|
||||
void FairMQSplitter::Run()
|
||||
{
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
auto& dataOutChannelRef = fChannels.at("data-out");
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
int numOutputs = dataOutChannelRef.size();
|
||||
std::vector<FairMQChannel*> dataOutChannels(numOutputs);
|
||||
for (int i = 0; i < numOutputs; ++i)
|
||||
{
|
||||
dataOutChannels[i] = &(dataOutChannelRef.at(i));
|
||||
}
|
||||
int numOutputs = fChannels.at("data-out").size();
|
||||
|
||||
int direction = 0;
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
FairMQParts parts;
|
||||
|
||||
if (dataInChannel.Receive(msg) >= 0)
|
||||
if (Receive(parts, "data-in") >= 0)
|
||||
{
|
||||
dataOutChannels[direction]->Send(msg);
|
||||
++direction;
|
||||
if (direction >= numOutputs)
|
||||
if (Send(parts, "data-out", direction) < 0)
|
||||
{
|
||||
direction = 0;
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(DEBUG) << "Transfer interrupted";
|
||||
break;
|
||||
}
|
||||
|
||||
++direction;
|
||||
if (direction >= numOutputs)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user