mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-17 18:41:46 +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
@@ -565,4 +565,5 @@ int FairMQSocketZMQ::GetConstant(const string& constant)
|
||||
|
||||
FairMQSocketZMQ::~FairMQSocketZMQ()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ class FairMQTransportFactoryZMQ : public FairMQTransportFactory
|
||||
{
|
||||
public:
|
||||
FairMQTransportFactoryZMQ();
|
||||
~FairMQTransportFactoryZMQ() override;
|
||||
|
||||
void Initialize(const FairMQProgOptions* config) override;
|
||||
|
||||
@@ -45,8 +46,6 @@ class FairMQTransportFactoryZMQ : public FairMQTransportFactory
|
||||
void Shutdown() override;
|
||||
void Terminate() override;
|
||||
|
||||
~FairMQTransportFactoryZMQ() override {};
|
||||
|
||||
private:
|
||||
static FairMQ::Transport fTransportType;
|
||||
void* fContext;
|
||||
|
Reference in New Issue
Block a user