add nanomsg implementations + use factory for nanomsg + lots of small stuff

This commit is contained in:
Alexey Rybalchenko
2014-01-24 15:54:29 +01:00
parent c041c14373
commit 64b9e991c3
44 changed files with 1138 additions and 420 deletions

View File

@@ -0,0 +1,53 @@
/**
* FairMQContextZMQ.cxx
*
* @since 2012-12-05
* @author D. Klein, A. Rybalchenko
*/
#include "FairMQLogger.h"
#include "FairMQContextZMQ.h"
#include <sstream>
FairMQContextZMQ::FairMQContextZMQ(int numIoThreads)
{
fContext = zmq_ctx_new ();
if (fContext == NULL){
stringstream logmsg;
logmsg << "failed creating context, reason: " << zmq_strerror(errno);
FairMQLogger::GetInstance()->Log(FairMQLogger::ERROR, logmsg.str());
}
int rc = zmq_ctx_set (fContext, ZMQ_IO_THREADS, numIoThreads);
if (rc != 0){
stringstream logmsg;
logmsg << "failed configuring context, reason: " << zmq_strerror(errno);
FairMQLogger::GetInstance()->Log(FairMQLogger::ERROR, logmsg.str());
}
}
FairMQContextZMQ::~FairMQContextZMQ()
{
Close();
}
void* FairMQContextZMQ::GetContext()
{
return fContext;
}
void FairMQContextZMQ::Close()
{
if (fContext == NULL){
return;
}
int rc = zmq_ctx_destroy (fContext);
if (rc != 0) {
stringstream logmsg;
logmsg << "failed closing context, reason: " << zmq_strerror(errno);
FairMQLogger::GetInstance()->Log(FairMQLogger::ERROR, logmsg.str());
}
fContext = NULL;
}