From 44a9946ea65bc756cfbf14dff3b8e8324c6cb38e Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Fri, 8 Mar 2019 14:53:46 +0100 Subject: [PATCH] Allow creating region with a callback with default transport --- fairmq/FairMQChannel.h | 5 +++++ fairmq/FairMQDevice.h | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fairmq/FairMQChannel.h b/fairmq/FairMQChannel.h index f0f79df0..87ef5be1 100644 --- a/fairmq/FairMQChannel.h +++ b/fairmq/FairMQChannel.h @@ -345,6 +345,11 @@ class FairMQChannel return Transport()->NewStaticMessage(data); } + FairMQUnmanagedRegionPtr NewUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr) + { + return Transport()->CreateUnmanagedRegion(size, callback); + } + private: std::shared_ptr fTransportFactory; fair::mq::Transport fTransportType; diff --git a/fairmq/FairMQDevice.h b/fairmq/FairMQDevice.h index 0c6ba4f8..228b7275 100644 --- a/fairmq/FairMQDevice.h +++ b/fairmq/FairMQDevice.h @@ -191,50 +191,58 @@ class FairMQDevice return fTransportFactory.get(); } + // creates message with the default device transport template FairMQMessagePtr NewMessage(Args&&... args) { return Transport()->CreateMessage(std::forward(args)...); } + // creates message with the transport of the specified channel template FairMQMessagePtr NewMessageFor(const std::string& channel, int index, Args&&... args) { return GetChannel(channel, index).NewMessage(std::forward(args)...); } + // creates a message that will not be cleaned up after transfer, with the default device transport template FairMQMessagePtr NewStaticMessage(const T& data) { return Transport()->NewStaticMessage(data); } + // creates a message that will not be cleaned up after transfer, with the transport of the specified channel template FairMQMessagePtr NewStaticMessageFor(const std::string& channel, int index, const T& data) { return GetChannel(channel, index).NewStaticMessage(data); } + // creates a message with a copy of the provided data, with the default device transport template FairMQMessagePtr NewSimpleMessage(const T& data) { return Transport()->NewSimpleMessage(data); } + // creates a message with a copy of the provided data, with the transport of the specified channel template FairMQMessagePtr NewSimpleMessageFor(const std::string& channel, int index, const T& data) { return GetChannel(channel, index).NewSimpleMessage(data); } - FairMQUnmanagedRegionPtr NewUnmanagedRegion(const size_t size) + // creates unamanaged region with the default device transport + FairMQUnmanagedRegionPtr NewUnmanagedRegion(const size_t size, FairMQRegionCallback callback = nullptr) { - return Transport()->CreateUnmanagedRegion(size); + return Transport()->CreateUnmanagedRegion(size, callback); } + // creates unmanaged region with the transport of the specified channel FairMQUnmanagedRegionPtr NewUnmanagedRegionFor(const std::string& channel, int index, const size_t size, FairMQRegionCallback callback = nullptr) { - return GetChannel(channel, index).Transport()->CreateUnmanagedRegion(size, callback); + return GetChannel(channel, index).NewUnmanagedRegion(size, callback); } template