mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +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 *>(
|
const_cast<typename std::remove_const<typename ContainerT::value_type>::type *>(
|
||||||
container.data())));
|
container.data())));
|
||||||
if (message)
|
if (message)
|
||||||
|
{
|
||||||
message->SetUsedSize(containerSizeBytes);
|
message->SetUsedSize(containerSizeBytes);
|
||||||
return message;
|
return message;
|
||||||
} else {
|
} else {
|
||||||
auto message = targetResource->getTransportFactory()->CreateMessage(containerSizeBytes);
|
//container is not required to allocate (like in std::string small string optimization)
|
||||||
std::memcpy(static_cast<fair::mq::byte *>(message->GetData()),
|
//in case we get no message we fall back to default (copy) behaviour)
|
||||||
container.data(),
|
targetResource = resource;
|
||||||
containerSizeBytes);
|
}
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto message = targetResource->getTransportFactory()->CreateMessage(containerSizeBytes);
|
||||||
|
std::memcpy(static_cast<fair::mq::byte *>(message->GetData()),
|
||||||
|
container.data(),
|
||||||
|
containerSizeBytes);
|
||||||
|
return message;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace mq */
|
} /* namespace mq */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user