mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Let getMessage deal with SSO
containers are not required to allocate, e.g. small string optimization for now this is hypothetical since we cannot use std::basic_string with at least gcc 7 since the basic_string there still uses the deprecated rebind allocator interface (which pmr does not implement)
This commit is contained in:
parent
ee24144d61
commit
0cb8f6166a
|
@ -45,15 +45,21 @@ FairMQMessagePtr getMessage(ContainerT &&container_, FairMQMemoryResource *targe
|
|||
const_cast<typename std::remove_const<typename ContainerT::value_type>::type *>(
|
||||
container.data())));
|
||||
if (message)
|
||||
{
|
||||
message->SetUsedSize(containerSizeBytes);
|
||||
return message;
|
||||
} else {
|
||||
auto message = targetResource->getTransportFactory()->CreateMessage(containerSizeBytes);
|
||||
std::memcpy(static_cast<fair::mq::byte *>(message->GetData()),
|
||||
container.data(),
|
||||
containerSizeBytes);
|
||||
return message;
|
||||
return message;
|
||||
} else {
|
||||
//container is not required to allocate (like in std::string small string optimization)
|
||||
//in case we get no message we fall back to default (copy) behaviour)
|
||||
targetResource = resource;
|
||||
}
|
||||
}
|
||||
|
||||
auto message = targetResource->getTransportFactory()->CreateMessage(containerSizeBytes);
|
||||
std::memcpy(static_cast<fair::mq::byte *>(message->GetData()),
|
||||
container.data(),
|
||||
containerSizeBytes);
|
||||
return message;
|
||||
};
|
||||
|
||||
} /* namespace mq */
|
||||
|
|
Loading…
Reference in New Issue
Block a user