Initialize shared memory only if it is used.

This commit is contained in:
Alexey Rybalchenko
2017-01-09 13:37:39 +01:00
committed by Mohammad Al-Turany
parent ac1da4db66
commit 8cf1cbb930
5 changed files with 43 additions and 35 deletions

View File

@@ -17,8 +17,8 @@ using namespace std;
using namespace FairMQ::shmem;
// Context to hold the ZeroMQ sockets
unique_ptr<FairMQContextSHM> FairMQSocketSHM::fContext = unique_ptr<FairMQContextSHM>(new FairMQContextSHM(1));
// bool FairMQSocketSHM::fContextInitialized = false;
unique_ptr<FairMQContextSHM> FairMQSocketSHM::fContext; // = unique_ptr<FairMQContextSHM>(new FairMQContextSHM(1));
bool FairMQSocketSHM::fContextInitialized = false;
FairMQSocketSHM::FairMQSocketSHM(const string& type, const string& name, const int numIoThreads, const string& id /*= ""*/)
: FairMQSocket(ZMQ_SNDMORE, ZMQ_RCVMORE, ZMQ_DONTWAIT)
@@ -31,11 +31,11 @@ FairMQSocketSHM::FairMQSocketSHM(const string& type, const string& name, const i
{
fId = id + "." + name + "." + type;
// if (!fContextInitialized)
// {
// fContext = unique_ptr<FairMQContextSHM>(new FairMQContextSHM(1));
// fContextInitialized = true;
// }
if (!fContextInitialized)
{
fContext = unique_ptr<FairMQContextSHM>(new FairMQContextSHM(1));
fContextInitialized = true;
}
if (zmq_ctx_set(fContext->GetContext(), ZMQ_IO_THREADS, numIoThreads) != 0)
{