-
-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for in-place instantiation of a shared message in the message pool #854
Conversation
Review changes with SemanticDiff. |
0d02eca
to
8d21338
Compare
8d21338
to
a196b48
Compare
…-message' into feature/in-place-construction-of-shared-message
I looked at the code and I've experimentally modified the code. I added a utility class
You'll notice that the emplace allocate function now takes the message type as a template parameter, rather than as a dummy pointer argument. I'll merge your code and add my changes. |
268ca4e
into
ETLCPP:pull-request/#854-in-place-construction-of-shared-message
…ge' of https://github.com/ETLCPP/etl into pull-request/#854-in-place-construction-of-shared-message
Great! |
I removed the |
First of all, thank you so much for writing the ETL!
With the current implementation of the reference counted message pool and the shared message, the message must first be created (e.g. on the stack) and is then copied into the message pool. However, sometimes a message needs to be instantiated in the message pool that is expensive to copy on an embedded platform.
If the message could be instantiated in-place in the memory pool (without a copy), this could save significant memory for certain use-cases.
This pull request is an example of what an implementation of in-place instantiation could look like.
The test suite is extended to demonstrate the usage (
message_pool.create_message<Message1>(1);
)In the test suite, the data element in the message is an
int
, but you can imagine this to be a type that is more expensive to copy.Note:
allocate(const TMessage*, Args&&... args)
passes a pointer toTMessage
, but it is only used to pass the type.There is undoubtedly a better way to achieve this, that I have not found to work yet.
Feel free to comment or request changes, I'd be happy to incorporate those.