Skip to content

Commit f775c5f

Browse files
mkrzewicmatthiasrichter
authored andcommitted
Implement comments by matthiasrichter
1 parent a44ffb3 commit f775c5f

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

DataFormats/MemoryResources/include/MemoryResources/MemoryResources.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ class ChannelResource : public FairMQMemoryResource
9191
void* do_allocate(std::size_t bytes, std::size_t alignment) override
9292
{
9393
FairMQMessagePtr message;
94-
if (!factory) {
95-
throw std::bad_alloc();
96-
} else {
97-
message = factory->CreateMessage(bytes);
98-
}
94+
message = factory->CreateMessage(bytes);
9995
void* addr = message->GetData();
10096
messageMap[addr] = std::move(message);
10197
return addr;
@@ -141,12 +137,12 @@ class SpectatorAllocator : public boost::container::pmr::polymorphic_allocator<T
141137
void destroy(U*...){};
142138
};
143139

144-
using FastSpectatorAllocator = SpectatorAllocator<byte>;
145-
using PMRAllocator = boost::container::pmr::polymorphic_allocator<byte>;
140+
using ByteSpectatorAllocator = SpectatorAllocator<byte>;
141+
using BytePmrAllocator = boost::container::pmr::polymorphic_allocator<byte>;
146142

147143
//__________________________________________________________________________________________________
148144
/// This memory resource only watches, does not allocate/deallocate anything.
149-
/// In combination with the FastSpectatorAllocator this is an alternative to using span, as raw memory
145+
/// In combination with the ByteSpectatorAllocator this is an alternative to using span, as raw memory
150146
/// (e.g. an existing buffer message) will be accessible with appropriate container.
151147
class SpectatorMessageResource : public FairMQMemoryResource
152148
{
@@ -224,7 +220,7 @@ template <typename ElemT>
224220
auto adoptVector(size_t nelem, FairMQMessage* message)
225221
{
226222
using namespace o2::memoryResources;
227-
using DataType = std::vector<ElemT, FastSpectatorAllocator>;
223+
using DataType = std::vector<ElemT, ByteSpectatorAllocator>;
228224

229225
struct doubleDeleter {
230226
// kids: don't do this at home! (but here it's OK)
@@ -236,7 +232,7 @@ auto adoptVector(size_t nelem, FairMQMessage* message)
236232
using OutputType = std::unique_ptr<const DataType, doubleDeleter>;
237233

238234
auto resource = std::make_unique<SpectatorMessageResource>(message);
239-
auto output = new DataType(nelem, FastSpectatorAllocator{ resource.get() });
235+
auto output = new DataType(nelem, ByteSpectatorAllocator{ resource.get() });
240236
return OutputType(output, doubleDeleter{ std::move(resource) });
241237
}
242238

DataFormats/MemoryResources/test/testMemoryResources.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(allocator_test)
102102
v.push_back(3);
103103
BOOST_CHECK(testData::nallocated == 3);
104104
}
105-
BOOST_CHECK(testData::nallocated == 3); //FastSpectatorAllocator does not call dtors so nallocated remains at 3;
105+
BOOST_CHECK(testData::nallocated == 3); //ByteSpectatorAllocator does not call dtors so nallocated remains at 3;
106106
BOOST_CHECK(allocZMQ->getNumberOfMessages() == 0);
107107
}
108108

0 commit comments

Comments
 (0)