mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Remove compile time transport interface switch
- Remove the compile time check of the transport implementation. The transport (zeromq/nanomsg) can be chosen at run time with: `device.SetTransport("zeromq"); // possible values are "zeromq" and "nanomsg"`. For devices that use FairMQProgOptions, the transport can be configured via cmd option: `--transport zeromq` or `--transport nanomsg`. Default values is "zeromq". The device receives the configured value with: `device.SetTransport(config.GetValue<std::string>("transport"));` Old method of setting transport still works. But the NANOMSG constant is not defined. - Remove old `fairmq/prototest` directory. It was only used as a test for protobuf. The protobuf part of Tutorial3 does the same (with different values). - Fix a bug in FairMQPollerNN, where the `revents` value was not initialized. This caused the `poller->CheckOutput()` to trigger when it should not.
This commit is contained in:
@@ -27,6 +27,11 @@
|
||||
#include "FairMQDevice.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#ifdef NANOMSG_FOUND
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
// boost::function and a wrapper to catch the signals
|
||||
@@ -85,6 +90,12 @@ void FairMQDevice::SignalHandler(int signal)
|
||||
|
||||
void FairMQDevice::InitWrapper()
|
||||
{
|
||||
if (!fTransportFactory)
|
||||
{
|
||||
LOG(ERROR) << "Transport not initialized. Did you call SetTransport()?";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!fCmdSocket)
|
||||
{
|
||||
fCmdSocket = fTransportFactory->CreateSocket("pub", "device-commands", fNumIoThreads);
|
||||
@@ -454,6 +465,32 @@ void FairMQDevice::SetTransport(FairMQTransportFactory* factory)
|
||||
fTransportFactory = factory;
|
||||
}
|
||||
|
||||
void FairMQDevice::SetTransport(const string& transport)
|
||||
{
|
||||
if (transport == "zeromq")
|
||||
{
|
||||
fTransportFactory = new FairMQTransportFactoryZMQ();
|
||||
}
|
||||
#ifdef NANOMSG_FOUND
|
||||
else if (transport == "nanomsg")
|
||||
{
|
||||
fTransportFactory = new FairMQTransportFactoryNN();
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
LOG(ERROR) << "Unknown transport implementation requested: "
|
||||
<< transport
|
||||
<< ". Supported are "
|
||||
<< "\"zeromq\""
|
||||
#ifdef NANOMSG_FOUND
|
||||
<< ", \"nanomsg\""
|
||||
#endif
|
||||
<< ". Exiting.";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQDevice::LogSocketRates()
|
||||
{
|
||||
timestamp_t t0;
|
||||
|
Reference in New Issue
Block a user