mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-17 10:31:46 +00:00
Replace tools::make_unique with std::make_unique
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include <FairMQLogger.h>
|
||||
#include <FairMQMessage.h>
|
||||
#include <fairmq/ProgOptions.h>
|
||||
#include <fairmq/tools/CppSTL.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
@@ -36,6 +35,7 @@
|
||||
|
||||
#include <cstdlib> // getenv
|
||||
#include <condition_variable>
|
||||
#include <memory> // make_unique
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
@@ -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<Region>(fShmId, id, size, false, callback, bulkCallback, path, flags));
|
||||
auto r = fRegions.emplace(id, std::make_unique<Region>(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<Region>(fShmId, id, 0, true, nullptr, nullptr, path, flags));
|
||||
auto r = fRegions.emplace(id, std::make_unique<Region>(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?";
|
||||
|
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <FairMQLogger.h>
|
||||
#include <FairMQUnmanagedRegion.h>
|
||||
#include <fairmq/tools/CppSTL.h>
|
||||
#include <fairmq/tools/Strings.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -32,6 +31,7 @@
|
||||
#include <algorithm> // min
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <memory> // make_unique
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <unordered_map>
|
||||
@@ -113,9 +113,9 @@ struct Region
|
||||
using namespace boost::interprocess;
|
||||
|
||||
if (fRemote) {
|
||||
fQueue = tools::make_unique<message_queue>(open_only, fQueueName.c_str());
|
||||
fQueue = std::make_unique<message_queue>(open_only, fQueueName.c_str());
|
||||
} else {
|
||||
fQueue = tools::make_unique<message_queue>(create_only, fQueueName.c_str(), 1024, fAckBunchSize * sizeof(RegionBlock));
|
||||
fQueue = std::make_unique<message_queue>(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<RegionBlock[]> blocks = tools::make_unique<RegionBlock[]>(fAckBunchSize);
|
||||
std::unique_ptr<RegionBlock[]> blocks = std::make_unique<RegionBlock[]>(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<RegionBlock[]> blocks = tools::make_unique<RegionBlock[]>(fAckBunchSize);
|
||||
std::unique_ptr<RegionBlock[]> blocks = std::make_unique<RegionBlock[]>(fAckBunchSize);
|
||||
std::vector<fair::mq::RegionBlock> result;
|
||||
result.reserve(fAckBunchSize);
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <zmq.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory> // 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<Message>(fManager, hdrVec[m], GetTransport()));
|
||||
msgVec.emplace_back(std::make_unique<Message>(fManager, hdrVec[m], GetTransport()));
|
||||
Message* shmMsg = static_cast<Message*>(msgVec.back().get());
|
||||
totalSize += shmMsg->GetSize();
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <zmq.h>
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
#include <memory> // unique_ptr, make_unique
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -86,7 +86,7 @@ class TransportFactory final : public fair::mq::TransportFactory
|
||||
LOG(error) << "failed configuring context, reason: " << zmq_strerror(errno);
|
||||
}
|
||||
|
||||
fManager = tools::make_unique<Manager>(fShmId, fDeviceId, segmentSize, config);
|
||||
fManager = std::make_unique<Manager>(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<Message>(*fManager, this);
|
||||
return std::make_unique<Message>(*fManager, this);
|
||||
}
|
||||
|
||||
MessagePtr CreateMessage(Alignment alignment) override
|
||||
{
|
||||
return tools::make_unique<Message>(*fManager, alignment, this);
|
||||
return std::make_unique<Message>(*fManager, alignment, this);
|
||||
}
|
||||
|
||||
MessagePtr CreateMessage(const size_t size) override
|
||||
{
|
||||
return tools::make_unique<Message>(*fManager, size, this);
|
||||
return std::make_unique<Message>(*fManager, size, this);
|
||||
}
|
||||
|
||||
MessagePtr CreateMessage(const size_t size, Alignment alignment) override
|
||||
{
|
||||
return tools::make_unique<Message>(*fManager, size, alignment, this);
|
||||
return std::make_unique<Message>(*fManager, size, alignment, this);
|
||||
}
|
||||
|
||||
MessagePtr CreateMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) override
|
||||
{
|
||||
return tools::make_unique<Message>(*fManager, data, size, ffn, hint, this);
|
||||
return std::make_unique<Message>(*fManager, data, size, ffn, hint, this);
|
||||
}
|
||||
|
||||
MessagePtr CreateMessage(UnmanagedRegionPtr& region, void* data, const size_t size, void* hint = 0) override
|
||||
{
|
||||
return tools::make_unique<Message>(*fManager, region, data, size, hint, this);
|
||||
return std::make_unique<Message>(*fManager, region, data, size, hint, this);
|
||||
}
|
||||
|
||||
SocketPtr CreateSocket(const std::string& type, const std::string& name) override
|
||||
{
|
||||
return tools::make_unique<Socket>(*fManager, type, name, GetId(), fZmqCtx, this);
|
||||
return std::make_unique<Socket>(*fManager, type, name, GetId(), fZmqCtx, this);
|
||||
}
|
||||
|
||||
PollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const override
|
||||
{
|
||||
return tools::make_unique<Poller>(channels);
|
||||
return std::make_unique<Poller>(channels);
|
||||
}
|
||||
|
||||
PollerPtr CreatePoller(const std::vector<FairMQChannel*>& channels) const override
|
||||
{
|
||||
return tools::make_unique<Poller>(channels);
|
||||
return std::make_unique<Poller>(channels);
|
||||
}
|
||||
|
||||
PollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const override
|
||||
{
|
||||
return tools::make_unique<Poller>(channelsMap, channelList);
|
||||
return std::make_unique<Poller>(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<UnmanagedRegion>(*fManager, size, userFlags, callback, bulkCallback, path, flags, this);
|
||||
return std::make_unique<UnmanagedRegion>(*fManager, size, userFlags, callback, bulkCallback, path, flags, this);
|
||||
}
|
||||
|
||||
void SubscribeToRegionEvents(RegionEventCallback callback) override { fManager->SubscribeToRegionEvents(callback); }
|
||||
|
Reference in New Issue
Block a user