diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index 7ee555e3..c4c64f6e 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -75,7 +75,7 @@ FairMQDevice::FairMQDevice(ProgOptions* config, const tools::Version version) : fTransportFactory(nullptr) , fTransports() , fChannels() - , fInternalConfig(config ? nullptr : tools::make_unique()) + , fInternalConfig(config ? nullptr : make_unique()) , fConfig(config ? config : fInternalConfig.get()) , fId(DefaultId) , fDefaultTransportType(DefaultTransportType) diff --git a/fairmq/Plugin.h b/fairmq/Plugin.h index cd7d70bc..870d5420 100644 --- a/fairmq/Plugin.h +++ b/fairmq/Plugin.h @@ -9,7 +9,6 @@ #ifndef FAIR_MQ_PLUGIN_H #define FAIR_MQ_PLUGIN_H -#include #include #include @@ -140,7 +139,7 @@ class Plugin #define REGISTER_FAIRMQ_PLUGIN(KLASS, NAME, VERSION, MAINTAINER, HOMEPAGE, PROGOPTIONS) \ static auto Make_##NAME##_Plugin(fair::mq::PluginServices* pluginServices) -> std::unique_ptr \ { \ - return fair::mq::tools::make_unique(std::string{#NAME}, VERSION, std::string{MAINTAINER}, std::string{HOMEPAGE}, pluginServices); \ + return std::make_unique(std::string{#NAME}, VERSION, std::string{MAINTAINER}, std::string{HOMEPAGE}, pluginServices); \ } \ BOOST_DLL_ALIAS(Make_##NAME##_Plugin, make_##NAME##_plugin) \ BOOST_DLL_ALIAS(PROGOPTIONS, get_##NAME##_plugin_progoptions) diff --git a/fairmq/PluginManager.h b/fairmq/PluginManager.h index d6206f52..eb5866ab 100644 --- a/fairmq/PluginManager.h +++ b/fairmq/PluginManager.h @@ -11,7 +11,6 @@ #include #include -#include #include #define BOOST_FILESYSTEM_VERSION 3 @@ -80,7 +79,7 @@ class PluginManager auto ForEachPluginProgOptions(std::function func) const -> void { for(const auto& pair : fPluginProgOptions) { func(pair.second); } } template - auto EmplacePluginServices(Args&&... args) -> void { fPluginServices = fair::mq::tools::make_unique(std::forward(args)...); } + auto EmplacePluginServices(Args&&... args) -> void { fPluginServices = std::make_unique(std::forward(args)...); } auto WaitForPluginsToReleaseDeviceControl() -> void { fPluginServices->WaitForReleaseDeviceControl(); } diff --git a/fairmq/ofi/Socket.cxx b/fairmq/ofi/Socket.cxx index 558fcea9..0a99e5c2 100644 --- a/fairmq/ofi/Socket.cxx +++ b/fairmq/ofi/Socket.cxx @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -74,16 +74,16 @@ auto Socket::InitOfi(Address addr) -> void hints.set_provider("verbs"); } if (fRemoteAddr == addr) { - fOfiInfo = tools::make_unique(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), 0, hints); + fOfiInfo = make_unique(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), 0, hints); } else { - fOfiInfo = tools::make_unique(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), FI_SOURCE, hints); + fOfiInfo = make_unique(addr.Ip.c_str(), std::to_string(addr.Port).c_str(), FI_SOURCE, hints); } LOG(debug) << "OFI transport (" << fId << "): " << *fOfiInfo; - fOfiFabric = tools::make_unique(*fOfiInfo); + fOfiFabric = make_unique(*fOfiInfo); - fOfiDomain = tools::make_unique(*fOfiFabric); + fOfiDomain = make_unique(*fOfiFabric); } } @@ -96,7 +96,7 @@ try { InitOfi(fLocalAddr); - fPassiveEndpoint = tools::make_unique(fContext.GetIoContext(), *fOfiFabric); + fPassiveEndpoint = make_unique(fContext.GetIoContext(), *fOfiFabric); //fPassiveEndpoint->set_local_address(Context::ConvertAddress(fLocalAddr)); BindControlEndpoint(); @@ -128,7 +128,7 @@ auto Socket::BindControlEndpoint() -> void fPassiveEndpoint->listen([&](asiofi::info&& info) { LOG(debug) << "OFI transport (" << fId << "): control band connection request received. Accepting ..."; - fControlEndpoint = tools::make_unique( + fControlEndpoint = make_unique( fContext.GetIoContext(), *fOfiDomain, info); fControlEndpoint->enable(); fControlEndpoint->accept([&]() { @@ -148,7 +148,7 @@ auto Socket::BindDataEndpoint() -> void fPassiveEndpoint->listen([&](asiofi::info&& info) { LOG(debug) << "OFI transport (" << fId << "): data band connection request received. Accepting ..."; - fDataEndpoint = tools::make_unique( + fDataEndpoint = make_unique( fContext.GetIoContext(), *fOfiDomain, info); fDataEndpoint->enable(); fDataEndpoint->accept([&]() { @@ -215,7 +215,7 @@ auto Socket::ConnectEndpoint(std::unique_ptr& endpoi std::string band(type == Band::Control ? "control" : "data"); - endpoint = tools::make_unique(fContext.GetIoContext(), *fOfiDomain); + endpoint = make_unique(fContext.GetIoContext(), *fOfiDomain); endpoint->enable(); LOG(debug) << "OFI transport (" << fId << "): Sending " << band << " band connection request to " << fRemoteAddr; diff --git a/fairmq/plugins/PMIx/PMIxCommands.h b/fairmq/plugins/PMIx/PMIxCommands.h index da2469d9..daaf03cb 100644 --- a/fairmq/plugins/PMIx/PMIxCommands.h +++ b/fairmq/plugins/PMIx/PMIxCommands.h @@ -13,7 +13,7 @@ #include #include -#include +#include // make_unique #include namespace pmix @@ -156,7 +156,7 @@ class Commands void Send(const std::string& msg, const std::vector& destination) { - std::unique_ptr holder = fair::mq::tools::make_unique(); + std::unique_ptr holder = std::make_unique(); PMIX_DATA_ARRAY_CREATE(holder->fData, destination.size(), PMIX_PROC); memcpy(holder->fData->array, destination.data(), destination.size() * sizeof(pmix_proc_t)); diff --git a/fairmq/sdk/commands/Commands.cxx b/fairmq/sdk/commands/Commands.cxx index 1a442333..463a4351 100644 --- a/fairmq/sdk/commands/Commands.cxx +++ b/fairmq/sdk/commands/Commands.cxx @@ -219,37 +219,37 @@ string Cmds::Serialize(const Format type) const switch (cmd->GetType()) { case Type::check_state: { - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); } break; case Type::change_state: { - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_transition(GetFBTransition(static_cast(*cmd).GetTransition())); } break; case Type::dump_config: { - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); } break; break; case Type::subscribe_to_state_change: { auto _cmd = static_cast(*cmd); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_interval(_cmd.GetInterval()); } break; case Type::unsubscribe_from_state_change: { - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); } break; case Type::state_change_exiting_received: { - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); } break; case Type::get_properties: { auto _cmd = static_cast(*cmd); auto query = fbb.CreateString(_cmd.GetQuery()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_property_query(query); } @@ -263,21 +263,21 @@ string Cmds::Serialize(const Format type) const propsVector.push_back(CreateFBProperty(fbb, key, val)); } auto props = fbb.CreateVector(propsVector); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_properties(props); } break; case Type::subscription_heartbeat: { auto _cmd = static_cast(*cmd); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_interval(_cmd.GetInterval()); } break; case Type::current_state: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_current_state(GetFBState(_cmd.GetCurrentState())); } @@ -285,7 +285,7 @@ string Cmds::Serialize(const Format type) const case Type::transition_status: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); @@ -297,7 +297,7 @@ string Cmds::Serialize(const Format type) const auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); auto config = fbb.CreateString(_cmd.GetConfig()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_config_string(config); } @@ -305,7 +305,7 @@ string Cmds::Serialize(const Format type) const case Type::state_change_subscription: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); @@ -314,7 +314,7 @@ string Cmds::Serialize(const Format type) const case Type::state_change_unsubscription: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); @@ -323,7 +323,7 @@ string Cmds::Serialize(const Format type) const case Type::state_change: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_task_id(_cmd.GetTaskId()); cmdBuilder->add_last_state(GetFBState(_cmd.GetLastState())); @@ -342,7 +342,7 @@ string Cmds::Serialize(const Format type) const propsVector.push_back(prop); } auto props = fbb.CreateVector(propsVector); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); @@ -352,7 +352,7 @@ string Cmds::Serialize(const Format type) const case Type::properties_set: { auto _cmd = static_cast(*cmd); auto deviceId = fbb.CreateString(_cmd.GetDeviceId()); - cmdBuilder = tools::make_unique(fbb); + cmdBuilder = make_unique(fbb); cmdBuilder->add_device_id(deviceId); cmdBuilder->add_request_id(_cmd.GetRequestId()); cmdBuilder->add_result(GetFBResult(_cmd.GetResult())); diff --git a/fairmq/sdk/commands/Commands.h b/fairmq/sdk/commands/Commands.h index 8e2b146b..919ac41e 100644 --- a/fairmq/sdk/commands/Commands.h +++ b/fairmq/sdk/commands/Commands.h @@ -10,7 +10,6 @@ #define FAIR_MQ_SDK_COMMANDFACTORY #include -#include #include #include @@ -354,7 +353,7 @@ struct PropertiesSet : Cmd { template std::unique_ptr make(Args&&... args) { - return fair::mq::tools::make_unique(std::forward(args)...); + return std::make_unique(std::forward(args)...); } struct Cmds diff --git a/fairmq/shmem/Manager.h b/fairmq/shmem/Manager.h index ba5473c2..a5c3283a 100644 --- a/fairmq/shmem/Manager.h +++ b/fairmq/shmem/Manager.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,7 @@ #include // getenv #include +#include // make_unique #include #include #include @@ -274,7 +274,7 @@ class Manager // create region info fShmRegions->emplace(id, RegionInfo(path.c_str(), flags, userFlags, fShmVoidAlloc)); - auto r = fRegions.emplace(id, tools::make_unique(fShmId, id, size, false, callback, bulkCallback, path, flags)); + auto r = fRegions.emplace(id, std::make_unique(fShmId, id, size, false, callback, bulkCallback, path, flags)); // LOG(debug) << "Created region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'"; r.first->second->StartReceivingAcks(); @@ -312,7 +312,7 @@ class Manager int flags = regionInfo.fFlags; // LOG(debug) << "Located remote region with id '" << id << "', path: '" << path << "', flags: '" << flags << "'"; - auto r = fRegions.emplace(id, tools::make_unique(fShmId, id, 0, true, nullptr, nullptr, path, flags)); + auto r = fRegions.emplace(id, std::make_unique(fShmId, id, 0, true, nullptr, nullptr, path, flags)); return r.first->second.get(); } catch (std::out_of_range& oor) { LOG(error) << "Could not get remote region with id '" << id << "'. Does the region creator run with the same session id?"; diff --git a/fairmq/shmem/Region.h b/fairmq/shmem/Region.h index b38e67ee..a8c54095 100644 --- a/fairmq/shmem/Region.h +++ b/fairmq/shmem/Region.h @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -32,6 +31,7 @@ #include // min #include #include +#include // make_unique #include #include #include @@ -113,9 +113,9 @@ struct Region using namespace boost::interprocess; if (fRemote) { - fQueue = tools::make_unique(open_only, fQueueName.c_str()); + fQueue = std::make_unique(open_only, fQueueName.c_str()); } else { - fQueue = tools::make_unique(create_only, fQueueName.c_str(), 1024, fAckBunchSize * sizeof(RegionBlock)); + fQueue = std::make_unique(create_only, fQueueName.c_str(), 1024, fAckBunchSize * sizeof(RegionBlock)); } LOG(debug) << "shmem: initialized region queue: " << fQueueName; } @@ -123,7 +123,7 @@ struct Region void StartSendingAcks() { fAcksSender = std::thread(&Region::SendAcks, this); } void SendAcks() { - std::unique_ptr blocks = tools::make_unique(fAckBunchSize); + std::unique_ptr blocks = std::make_unique(fAckBunchSize); size_t blocksToSend = 0; while (true) { @@ -165,7 +165,7 @@ struct Region { unsigned int priority; boost::interprocess::message_queue::size_type recvdSize; - std::unique_ptr blocks = tools::make_unique(fAckBunchSize); + std::unique_ptr blocks = std::make_unique(fAckBunchSize); std::vector result; result.reserve(fAckBunchSize); diff --git a/fairmq/shmem/Socket.h b/fairmq/shmem/Socket.h index c2ef962e..474fa30c 100644 --- a/fairmq/shmem/Socket.h +++ b/fairmq/shmem/Socket.h @@ -20,6 +20,7 @@ #include #include +#include // make_unique class FairMQTransportFactory; @@ -317,7 +318,7 @@ class Socket final : public fair::mq::Socket for (size_t m = 0; m < numMessages; m++) { // create new message (part) - msgVec.emplace_back(tools::make_unique(fManager, hdrVec[m], GetTransport())); + msgVec.emplace_back(std::make_unique(fManager, hdrVec[m], GetTransport())); Message* shmMsg = static_cast(msgVec.back().get()); totalSize += shmMsg->GetSize(); } diff --git a/fairmq/shmem/TransportFactory.h b/fairmq/shmem/TransportFactory.h index 5d5ddaaa..ee226ca0 100644 --- a/fairmq/shmem/TransportFactory.h +++ b/fairmq/shmem/TransportFactory.h @@ -25,7 +25,7 @@ #include -#include // unique_ptr +#include // unique_ptr, make_unique #include #include @@ -86,7 +86,7 @@ class TransportFactory final : public fair::mq::TransportFactory LOG(error) << "failed configuring context, reason: " << zmq_strerror(errno); } - fManager = tools::make_unique(fShmId, fDeviceId, segmentSize, config); + fManager = std::make_unique(fShmId, fDeviceId, segmentSize, config); } catch (boost::interprocess::interprocess_exception& e) { LOG(error) << "Could not initialize shared memory transport: " << e.what(); throw std::runtime_error(tools::ToString("Could not initialize shared memory transport: ", e.what())); @@ -98,52 +98,52 @@ class TransportFactory final : public fair::mq::TransportFactory MessagePtr CreateMessage() override { - return tools::make_unique(*fManager, this); + return std::make_unique(*fManager, this); } MessagePtr CreateMessage(Alignment alignment) override { - return tools::make_unique(*fManager, alignment, this); + return std::make_unique(*fManager, alignment, this); } MessagePtr CreateMessage(const size_t size) override { - return tools::make_unique(*fManager, size, this); + return std::make_unique(*fManager, size, this); } MessagePtr CreateMessage(const size_t size, Alignment alignment) override { - return tools::make_unique(*fManager, size, alignment, this); + return std::make_unique(*fManager, size, alignment, this); } MessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) override { - return tools::make_unique(*fManager, data, size, ffn, hint, this); + return std::make_unique(*fManager, data, size, ffn, hint, this); } MessagePtr CreateMessage(UnmanagedRegionPtr& region, void* data, const size_t size, void* hint = 0) override { - return tools::make_unique(*fManager, region, data, size, hint, this); + return std::make_unique(*fManager, region, data, size, hint, this); } SocketPtr CreateSocket(const std::string& type, const std::string& name) override { - return tools::make_unique(*fManager, type, name, GetId(), fZmqCtx, this); + return std::make_unique(*fManager, type, name, GetId(), fZmqCtx, this); } PollerPtr CreatePoller(const std::vector& channels) const override { - return tools::make_unique(channels); + return std::make_unique(channels); } PollerPtr CreatePoller(const std::vector& channels) const override { - return tools::make_unique(channels); + return std::make_unique(channels); } PollerPtr CreatePoller(const std::unordered_map>& channelsMap, const std::vector& channelList) const override { - return tools::make_unique(channelsMap, channelList); + return std::make_unique(channelsMap, channelList); } UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, RegionCallback callback = nullptr, const std::string& path = "", int flags = 0) override @@ -168,7 +168,7 @@ class TransportFactory final : public fair::mq::TransportFactory UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, int64_t userFlags, RegionCallback callback, RegionBulkCallback bulkCallback, const std::string& path, int flags) { - return tools::make_unique(*fManager, size, userFlags, callback, bulkCallback, path, flags, this); + return std::make_unique(*fManager, size, userFlags, callback, bulkCallback, path, flags, this); } void SubscribeToRegionEvents(RegionEventCallback callback) override { fManager->SubscribeToRegionEvents(callback); } diff --git a/fairmq/tools/CppSTL.h b/fairmq/tools/CppSTL.h index 2892e187..4789778b 100644 --- a/fairmq/tools/CppSTL.h +++ b/fairmq/tools/CppSTL.h @@ -20,20 +20,6 @@ namespace mq namespace tools { -// make_unique implementation, until C++14 is default -template -std::unique_ptr make_unique(Args&& ...args) -{ - return std::unique_ptr(new T(std::forward(args)...)); -} - -// make_unique implementation (array variant), until C++14 is default -template -std::unique_ptr make_unique(std::size_t size) -{ - return std::unique_ptr(new typename std::remove_extent::type[size]()); -} - // provide an enum hasher to compensate std::hash not supporting enums in C++11 template struct HashEnum diff --git a/fairmq/zeromq/Message.h b/fairmq/zeromq/Message.h index 344855f9..f56f5283 100644 --- a/fairmq/zeromq/Message.h +++ b/fairmq/zeromq/Message.h @@ -9,7 +9,6 @@ #ifndef FAIR_MQ_ZMQ_MESSAGE_H #define FAIR_MQ_ZMQ_MESSAGE_H -#include #include #include #include @@ -20,7 +19,7 @@ #include #include // malloc #include -#include +#include // make_unique #include // bad_alloc #include @@ -41,7 +40,7 @@ class Message final : public fair::mq::Message Message(FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(0) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { if (zmq_msg_init(fMsg.get()) != 0) { LOG(error) << "failed initializing message, reason: " << zmq_strerror(errno); @@ -51,7 +50,7 @@ class Message final : public fair::mq::Message Message(Alignment alignment, FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(alignment.alignment) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { if (zmq_msg_init(fMsg.get()) != 0) { LOG(error) << "failed initializing message, reason: " << zmq_strerror(errno); @@ -61,7 +60,7 @@ class Message final : public fair::mq::Message Message(const size_t size, FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(0) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { if (zmq_msg_init_size(fMsg.get(), size) != 0) { LOG(error) << "failed initializing message with size, reason: " << zmq_strerror(errno); @@ -85,7 +84,7 @@ class Message final : public fair::mq::Message Message(const size_t size, Alignment alignment, FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(alignment.alignment) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { if (fAlignment != 0) { auto ptrs = AllocateAligned(size, fAlignment); @@ -102,7 +101,7 @@ class Message final : public fair::mq::Message Message(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr, FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(0) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { if (zmq_msg_init_data(fMsg.get(), data, size, ffn, hint) != 0) { LOG(error) << "failed initializing message with data, reason: " << zmq_strerror(errno); @@ -112,7 +111,7 @@ class Message final : public fair::mq::Message Message(UnmanagedRegionPtr& region, void* data, const size_t size, void* hint = 0, FairMQTransportFactory* factory = nullptr) : fair::mq::Message(factory) , fAlignment(0) - , fMsg(tools::make_unique()) + , fMsg(std::make_unique()) { // FIXME: make this zero-copy: // simply taking over the provided buffer can casue premature delete, since region could be @@ -140,7 +139,7 @@ class Message final : public fair::mq::Message void Rebuild() override { CloseMessage(); - fMsg = tools::make_unique(); + fMsg = std::make_unique(); if (zmq_msg_init(fMsg.get()) != 0) { LOG(error) << "failed initializing message, reason: " << zmq_strerror(errno); } @@ -150,7 +149,7 @@ class Message final : public fair::mq::Message { CloseMessage(); fAlignment = alignment.alignment; - fMsg = tools::make_unique(); + fMsg = std::make_unique(); if (zmq_msg_init(fMsg.get()) != 0) { LOG(error) << "failed initializing message, reason: " << zmq_strerror(errno); } @@ -159,7 +158,7 @@ class Message final : public fair::mq::Message void Rebuild(const size_t size) override { CloseMessage(); - fMsg = tools::make_unique(); + fMsg = std::make_unique(); if (zmq_msg_init_size(fMsg.get(), size) != 0) { LOG(error) << "failed initializing message with size, reason: " << zmq_strerror(errno); } @@ -169,7 +168,7 @@ class Message final : public fair::mq::Message { CloseMessage(); fAlignment = alignment.alignment; - fMsg = tools::make_unique(); + fMsg = std::make_unique(); if (fAlignment != 0) { auto ptrs = AllocateAligned(size, fAlignment); @@ -186,7 +185,7 @@ class Message final : public fair::mq::Message void Rebuild(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) override { CloseMessage(); - fMsg = tools::make_unique(); + fMsg = std::make_unique(); if (zmq_msg_init_data(fMsg.get(), data, size, ffn, hint) != 0) { LOG(error) << "failed initializing message with data, reason: " << zmq_strerror(errno); } @@ -217,7 +216,7 @@ class Message final : public fair::mq::Message LOG(error) << "cannot set used size higher than original."; return false; } else { - auto newMsg = tools::make_unique(); + auto newMsg = std::make_unique(); void* data = GetData(); if (zmq_msg_init_data(newMsg.get(), data, size, [](void* /* data */, void* obj) { zmq_msg_close(static_cast(obj)); diff --git a/fairmq/zeromq/Socket.h b/fairmq/zeromq/Socket.h index 4ad5ef73..6ae45ee6 100644 --- a/fairmq/zeromq/Socket.h +++ b/fairmq/zeromq/Socket.h @@ -19,7 +19,7 @@ #include #include -#include // unique_ptr +#include // unique_ptr, make_unique namespace fair { namespace mq { @@ -258,7 +258,7 @@ class Socket final : public fair::mq::Socket bool repeat = false; do { - FairMQMessagePtr part = tools::make_unique(GetTransport()); + FairMQMessagePtr part = std::make_unique(GetTransport()); int nbytes = zmq_msg_recv(static_cast(part.get())->GetMessage(), fSocket, flags); if (nbytes >= 0) { @@ -328,8 +328,7 @@ class Socket final : public fair::mq::Socket { size_t eventsSize = sizeof(uint32_t); if (zmq_getsockopt(fSocket, ZMQ_EVENTS, events, &eventsSize) < 0) { - throw SocketError( - tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno))); + throw SocketError(tools::ToString("failed setting ZMQ_EVENTS, reason: ", zmq_strerror(errno))); } } diff --git a/fairmq/zeromq/TransportFactory.h b/fairmq/zeromq/TransportFactory.h index 2a18d184..14efe016 100644 --- a/fairmq/zeromq/TransportFactory.h +++ b/fairmq/zeromq/TransportFactory.h @@ -18,7 +18,7 @@ #include #include -#include // unique_ptr +#include // unique_ptr, make_unique #include #include @@ -41,10 +41,10 @@ class TransportFactory final : public FairMQTransportFactory LOG(debug) << "Transport: Using ZeroMQ library, version: " << major << "." << minor << "." << patch; if (config) { - fCtx = tools::make_unique(config->GetProperty("io-threads", 1)); + fCtx = std::make_unique(config->GetProperty("io-threads", 1)); } else { LOG(debug) << "fair::mq::ProgOptions not available! Using defaults."; - fCtx = tools::make_unique(1); + fCtx = std::make_unique(1); } } @@ -53,52 +53,52 @@ class TransportFactory final : public FairMQTransportFactory MessagePtr CreateMessage() override { - return tools::make_unique(this); + return std::make_unique(this); } MessagePtr CreateMessage(Alignment alignment) override { - return tools::make_unique(alignment, this); + return std::make_unique(alignment, this); } MessagePtr CreateMessage(const size_t size) override { - return tools::make_unique(size, this); + return std::make_unique(size, this); } MessagePtr CreateMessage(const size_t size, Alignment alignment) override { - return tools::make_unique(size, alignment, this); + return std::make_unique(size, alignment, this); } MessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) override { - return tools::make_unique(data, size, ffn, hint, this); + return std::make_unique(data, size, ffn, hint, this); } MessagePtr CreateMessage(UnmanagedRegionPtr& region, void* data, const size_t size, void* hint = 0) override { - return tools::make_unique(region, data, size, hint, this); + return std::make_unique(region, data, size, hint, this); } SocketPtr CreateSocket(const std::string& type, const std::string& name) override { - return tools::make_unique(*fCtx, type, name, GetId(), this); + return std::make_unique(*fCtx, type, name, GetId(), this); } PollerPtr CreatePoller(const std::vector& channels) const override { - return tools::make_unique(channels); + return std::make_unique(channels); } PollerPtr CreatePoller(const std::vector& channels) const override { - return tools::make_unique(channels); + return std::make_unique(channels); } PollerPtr CreatePoller(const std::unordered_map>& channelsMap, const std::vector& channelList) const override { - return tools::make_unique(channelsMap, channelList); + return std::make_unique(channelsMap, channelList); } UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, RegionCallback callback, const std::string& path = "", int flags = 0) override @@ -123,7 +123,7 @@ class TransportFactory final : public FairMQTransportFactory UnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, const int64_t userFlags, RegionCallback callback, RegionBulkCallback bulkCallback, const std::string&, int) { - UnmanagedRegionPtr ptr = tools::make_unique(*fCtx, size, userFlags, callback, bulkCallback, this); + UnmanagedRegionPtr ptr = std::make_unique(*fCtx, size, userFlags, callback, bulkCallback, this); auto zPtr = static_cast(ptr.get()); fCtx->AddRegion(false, zPtr->GetId(), zPtr->GetData(), zPtr->GetSize(), zPtr->GetUserFlags(), RegionEvent::created); return ptr;