# FairMQ: fairmq/shmem/TransportFactory.h Source File

TransportFactory.h
/********************************************************************************
* Copyright (C) 2016-2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef FAIR_MQ_SHMEM_TRANSPORTFACTORY_H_
#define FAIR_MQ_SHMEM_TRANSPORTFACTORY_H_
#include "Manager.h"
#include "Common.h"
#include "Message.h"
#include "Socket.h"
#include "Poller.h"
#include "UnmanagedRegion.h"
#include <FairMQTransportFactory.h>
#include <fairmq/ProgOptions.h>
#include <vector>
#include <string>
#include <thread>
#include <atomic>
namespace fair
{
namespace mq
{
namespace shmem
{
class TransportFactory final : public fair::mq::TransportFactory
{
public:
TransportFactory(const std::string& id = "", const ProgOptions* config = nullptr);
TransportFactory(const TransportFactory&) = delete;
TransportFactory operator=(const TransportFactory&) = delete;
MessagePtr CreateMessage() override;
MessagePtr CreateMessage(const size_t size) override;
MessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) override;
MessagePtr CreateMessage(UnmanagedRegionPtr& region, void* data, const size_t size, void* hint = 0) override;
SocketPtr CreateSocket(const std::string& type, const std::string& name) override;
PollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const override;
PollerPtr CreatePoller(const std::vector<FairMQChannel*>& channels) const override;
PollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const override;
UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, RegionCallback callback = nullptr, const std::string& path = "", int flags = 0) const override;
UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, int64_t userFlags, RegionCallback callback = nullptr, const std::string& path = "", int flags = 0) const override;
void SubscribeToRegionEvents(RegionEventCallback callback) override;
void UnsubscribeFromRegionEvents() override;
std::vector<fair::mq::RegionInfo> GetRegionInfo() override;
Transport GetType() const override;
void Interrupt() override { fManager->Interrupt(); }
void Resume() override { fManager->Resume(); }
void Reset() override;
void IncrementMsgCounter() { ++fMsgCounter; }
void DecrementMsgCounter() { --fMsgCounter; }
~TransportFactory() override;
private:
void SendHeartbeats();
static Transport fTransportType;
std::string fDeviceId;
std::string fShmId;
void* fZMQContext;
std::unique_ptr<Manager> fManager;
std::thread fHeartbeatThread;
std::atomic<bool> fSendHeartbeats;
std::atomic<int32_t> fMsgCounter;
};
} // namespace shmem
} // namespace mq
} // namespace fair
#endif /* FAIR_MQ_SHMEM_TRANSPORTFACTORY_H_ */
fair::mq::shmem::TransportFactory::CreatePoller
PollerPtr CreatePoller(const std::vector< FairMQChannel > &channels) const override
Create a poller for a single channel (all subchannels)
fair::mq::shmem::TransportFactory::CreateSocket
SocketPtr CreateSocket(const std::string &type, const std::string &name) override
Create a socket.
FairMQTransportFactory
Definition: FairMQTransportFactory.h:30
fair::mq::shmem::TransportFactory::CreateUnmanagedRegion
UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, RegionCallback callback=nullptr, const std::string &path="", int flags=0) const override
Create new UnmanagedRegion.
Definition: TransportFactory.cxx:162
fair::mq::shmem::TransportFactory::CreateMessage
MessagePtr CreateMessage() override
Create empty FairMQMessage.
Definition: TransportFactory.cxx:121
fair::mq::ProgOptions
Definition: ProgOptions.h:36
fair::mq::shmem::TransportFactory
Definition: TransportFactory.h:34
fair::mq::shmem::TransportFactory::UnsubscribeFromRegionEvents
void UnsubscribeFromRegionEvents() override
Unsubscribe from region events.
Definition: TransportFactory.cxx:177
fair
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
fair::mq::shmem::TransportFactory::GetType
Transport GetType() const override
Get transport type.
Definition: TransportFactory.cxx:187
fair::mq::shmem::TransportFactory::SubscribeToRegionEvents
void SubscribeToRegionEvents(RegionEventCallback callback) override
Subscribe to region events (creation, destruction, ...)
Definition: TransportFactory.cxx:172

privacy