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:
Dennis Klein
2017-05-14 17:10:57 +02:00
committed by Mohammad Al-Turany
parent 87252edbe0
commit 3205e0c378
12 changed files with 78 additions and 55 deletions

View File

@@ -1235,45 +1235,7 @@ void FairMQDevice::Exit()
t.second->Shutdown();
}
LOG(DEBUG) << "Closing sockets...";
// iterate over the channels
for (auto& c : fChannels)
{
// iterate over the sub-channels
for (auto& sc : c.second)
{
if (sc.fSocket)
{
sc.fSocket->Close();
sc.fSocket = nullptr;
}
if (sc.fChannelCmdSocket)
{
sc.fChannelCmdSocket->Close();
sc.fChannelCmdSocket = nullptr;
}
if (sc.fPoller)
{
sc.fPoller = nullptr;
}
}
}
for (auto& s : fDeviceCmdSockets)
{
s.second->Close();
}
LOG(DEBUG) << "Closed all sockets!";
// ask transports to terminate
for (const auto& t : fTransports)
{
t.second->Terminate();
}
LOG(DEBUG) << "All transports exited.";
LOG(DEBUG) << "All transports are shut down.";
}
FairMQDevice::~FairMQDevice()