mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 10:01:47 +00:00
refactor to more idiomatic RAII
* FairMQTransportFactoryZMQ: move the config invariant initialization to ctor * FairMQChannel: add new ctor that creates usable channel * FairMQSocket*: close sockets in dtor * FairMQTransportFactory*: terminate context in dtor * FairMQChannel: add Bind/Connect facades (for explicit control, e.g. timing)
This commit is contained in:
committed by
Mohammad Al-Turany
parent
87252edbe0
commit
3205e0c378
@@ -33,6 +33,11 @@ FairMQTransportFactoryZMQ::FairMQTransportFactoryZMQ()
|
||||
LOG(ERROR) << "failed creating context, reason: " << zmq_strerror(errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (zmq_ctx_set(fContext, ZMQ_MAX_SOCKETS, 10000) != 0)
|
||||
{
|
||||
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQTransportFactoryZMQ::Initialize(const FairMQProgOptions* config)
|
||||
@@ -51,12 +56,6 @@ void FairMQTransportFactoryZMQ::Initialize(const FairMQProgOptions* config)
|
||||
{
|
||||
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
|
||||
}
|
||||
|
||||
// Set the maximum number of allowed sockets on the context.
|
||||
if (zmq_ctx_set(fContext, ZMQ_MAX_SOCKETS, 10000) != 0)
|
||||
{
|
||||
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
|
||||
}
|
||||
}
|
||||
|
||||
FairMQMessagePtr FairMQTransportFactoryZMQ::CreateMessage() const
|
||||
@@ -130,3 +129,8 @@ void FairMQTransportFactoryZMQ::Terminate()
|
||||
LOG(ERROR) << "shmem: Terminate(): context now available for shutdown";
|
||||
}
|
||||
}
|
||||
|
||||
FairMQTransportFactoryZMQ::~FairMQTransportFactoryZMQ()
|
||||
{
|
||||
Terminate();
|
||||
}
|
||||
|
Reference in New Issue
Block a user