-
Notifications
You must be signed in to change notification settings - Fork 374
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
Iox #391 static memory alternative for std function #473
Iox #391 static memory alternative for std function #473
Conversation
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
… bug Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
… pointer Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only reviewed function_ref
and type_trait
changes so far.
iceoryx_utils/include/iceoryx_utils/internal/cxx/function_ref.inl
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
{ | ||
namespace cxx | ||
{ | ||
/// @note set the storage type and reorder template arguments for the user API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some punctuation would help with readability.
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.inl
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.inl
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.inl
Outdated
Show resolved
Hide resolved
Idea looks sound to me. Just needs some documentation ! |
@ithier. I will improve the documentation. I prefer brief docu though, unless the use cases are very tricky. No one reads long docu for functions or classes. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Tests are not yet reviewed.
- Please check if the implementation of
storable_function
can be simplified by using one generic c'tor, as instd::function
:
template< class F, class Alloc >
function( std::allocator_arg_t, const Alloc& alloc, F f );
- Align
cxx::PoorMansHeap
usage
iceoryx_utils/include/iceoryx_utils/internal/cxx/function_ref.inl
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.inl
Outdated
Show resolved
Hide resolved
I will update the PR in a day or two, until then no further review needed. |
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.inl
Outdated
Show resolved
Hide resolved
…rable Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
…rnative-for-std-function
Reworked, can be reviewed now. |
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only partially reviewed I will continue on monday.
Please adjust all copyright headers.
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/static_storage.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.hpp
Outdated
Show resolved
Hide resolved
iceoryx_utils/include/iceoryx_utils/internal/cxx/storable_function.inl
Outdated
Show resolved
Hide resolved
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
The pipeline reports a problem with Also needed to remove a test for the static storage which essentially checked that deallocation does not actually clear the storage but to do so caused an uninitialized read warning (unavoidable in this case I think). Test removed since this is no real requirement for functionality, just an aspect of optimization (i.e. not setting the memory to zero as most allocators do). |
Stale review, changed quite a bit and addressed all points.
@elfenpiff @mossmaurice I think I addressed all the points and the CI is green. It is by no means perfect, but I think it is mature enough to be tried out internally. Should there be any further issues I will find them when I replace internal |
👍 I'll finish off the review tonight. Could you merge |
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
b98e88f
to
a4c4971
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10/13 done
iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/static_storage.inl
Outdated
Show resolved
Hide resolved
iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/static_storage.inl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, only minor findings. Let's get this merged!
Another thing that just popped up: As this PR introduced a lot of new code, could you run Axivion with these coding rules over this PR (soon it will run with every PR)? |
No, in my opinion we will introduce Axivion for the whole code base and from then on we will run it for every PR. I have no license for it yet and do not see that we should block the PR due to this. I will fix any problem occurring due to this in a new PR, but we should introduce Axivion properly before this is done. |
60ef050
to
a4c4971
Compare
…rnative-for-std-function
Signed-off-by: Matthias Killat <matthias.killat@apex.ai>
Now it should be ok if the CI builds, wanted to get rid off one merge commit at least hence the force pushes. |
Could you create an issue for that? Axivion was introduced in #409 for the |
Before we create any issue we should wait whether anything pops up at all. |
@elfenpiff @mossmaurice should be ready to merge |
Pre-Review Checklist for the PR Author
iox-#123-this-is-a-branch
)iox-#123 commit text
)git commit -s
)Notes for Reviewer
Checklist for the PR Reviewer
Post-review Checklist for the PR Author
Post-review Checklist for the Eclipse Committer
References
Summary
Added a static storage alternative for std::function including tests. This is supposed to store any callable up to a given storage size. As is also the case for sd::function, it cannot e used in shared memory (this cannot be avoided due to the fact that pointers to e.g. free functions but also lambdas are stored which will usually not be valid in another process).
The implementation uses cxx::function_ref, otherwise parts of those functionality would have been rewritten/duplicated. It is important to note that much of the complications arise due to the fact that information about the underlying stored type is lost but it still must be ensured that it is copied/moved properly (according to RAII). Naturally these problems do NOT arise when only a reference is stored (as in function_ref).
Fixed an issue that function_ref was not constructible from function pointers of free functions (only function names, but those are not function pointers but are converted to them). There is still an open point of a conversion from something potentially not convertible to a void pointer in the function_ref ctor (existed before as well, as it would take a universal reference to anything callable). For function_pointers this is compliant with the POSIX standard, but in general it is not (function pointers cannot be converted to void pointers in general).
This requires some further investigation. A potential fix could be added here as well.