generate id if no device id available

* CreateSocket factory no longer accepts id param, but the
    TransportFactory has an id member instead
This commit is contained in:
Dennis Klein
2017-05-16 18:26:24 +02:00
committed by Mohammad Al-Turany
parent eb614b6005
commit 3be2f297f3
10 changed files with 101 additions and 91 deletions

View File

@@ -1,10 +1,16 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2016-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "FairMQLogger.h"
#include "FairMQShmManager.h"
#include "FairMQTransportFactorySHM.h"
#include "../options/FairMQProgOptions.h"
#include <zmq.h>
#include <boost/version.hpp>
@@ -17,11 +23,6 @@
#include <chrono>
#include "FairMQLogger.h"
#include "FairMQShmManager.h"
#include "FairMQTransportFactorySHM.h"
#include "../options/FairMQProgOptions.h"
using namespace std;
using namespace fair::mq::shmem;
namespace bipc = boost::interprocess;
@@ -29,8 +30,9 @@ namespace bpt = boost::posix_time;
FairMQ::Transport FairMQTransportFactorySHM::fTransportType = FairMQ::Transport::SHM;
FairMQTransportFactorySHM::FairMQTransportFactorySHM()
: fContext(nullptr)
FairMQTransportFactorySHM::FairMQTransportFactorySHM(const string& id)
: FairMQTransportFactory(id)
, fContext(nullptr)
, fHeartbeatSocket(nullptr)
, fHeartbeatThread()
, fSendHeartbeats(true)
@@ -144,10 +146,10 @@ FairMQMessagePtr FairMQTransportFactorySHM::CreateMessage(void* data, const size
return unique_ptr<FairMQMessage>(new FairMQMessageSHM(data, size, ffn, hint));
}
FairMQSocketPtr FairMQTransportFactorySHM::CreateSocket(const string& type, const string& name, const string& id /*= ""*/) const
FairMQSocketPtr FairMQTransportFactorySHM::CreateSocket(const string& type, const string& name) const
{
assert(fContext);
return unique_ptr<FairMQSocket>(new FairMQSocketSHM(type, name, id, fContext));
return unique_ptr<FairMQSocket>(new FairMQSocketSHM(type, name, GetId(), fContext));
}
FairMQPollerPtr FairMQTransportFactorySHM::CreatePoller(const vector<FairMQChannel>& channels) const

View File

@@ -1,13 +1,20 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* Copyright (C) 2016-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef FAIRMQTRANSPORTFACTORYSHM_H_
#define FAIRMQTRANSPORTFACTORYSHM_H_
#include "FairMQTransportFactory.h"
#include "FairMQMessageSHM.h"
#include "FairMQSocketSHM.h"
#include "FairMQPollerSHM.h"
#include "FairMQShmDeviceCounter.h"
#include <vector>
#include <string>
#include <thread>
@@ -15,16 +22,11 @@
#include <boost/interprocess/sync/named_mutex.hpp>
#include "FairMQTransportFactory.h"
#include "FairMQMessageSHM.h"
#include "FairMQSocketSHM.h"
#include "FairMQPollerSHM.h"
#include "FairMQShmDeviceCounter.h"
class FairMQTransportFactorySHM : public FairMQTransportFactory
{
public:
FairMQTransportFactorySHM();
FairMQTransportFactorySHM(const std::string& id = "");
void Initialize(const FairMQProgOptions* config) override;
@@ -32,7 +34,7 @@ class FairMQTransportFactorySHM : public FairMQTransportFactory
FairMQMessagePtr CreateMessage(const size_t size) const override;
FairMQMessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) const override;
FairMQSocketPtr CreateSocket(const std::string& type, const std::string& name, const std::string& id = "") const override;
FairMQSocketPtr CreateSocket(const std::string& type, const std::string& name) const override;
FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const override;
FairMQPollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const override;