-
Notifications
You must be signed in to change notification settings - Fork 504
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
Fix for issue 416: Impossible to retain transfer ids #420
Conversation
@@ -0,0 +1,228 @@ | |||
/// @copyright |
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.
JFYI, this is not a new file, but rename and a bit modification of the above transfer_id_generators.hpp
|
/// B/c modulo is expected to be quite big (like >= 2^48), collisions of transfer ids are unlikely. | ||
/// Normally in use for UDP transport, where the modulo is `2^64 - 1`. | ||
/// | ||
class TrivialTransferIdGenerator |
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.
We probably should mention that these generators are not thread-safe
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.
Whole libcyphal is not thread-safe.
/// Users may provide a custom implementation of this interface to maintain/persist transfer IDs. | ||
/// See `Presentation::setTransferIdMap` method for more details. | ||
/// | ||
class ITransferIdMap |
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.
I think we're getting a little too OOP here. The map type should be STL-compliant and defined in config.hpp (see #419). We can use cavl to implement a cetl::pmr O(log n) implementation that is enough of a std::map
duck type to cover our use cases and users can chose to redefine to std::pmr::unordered_map
when using C++17.
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.
Maybe if such type will be just memory-only container. But...
- the idea is to have persisting when needed
- currently interface is very clear. without c++20 concepts it becomes very blurry (should I use
operator []
orinsert
/remove
, and so on...) - in unit tests I have and use gmock of the interface - gives me very nice observability with minimum efforts
- this is optional feature of libcyphal - it works totally fine without it
- how much do you really save avoiding one virtual call for such relatively rare operations...?
- it's so easy to write a simple wrapper around whatever already existing STL collection. I can even add an example in the docs if you think it could be a showstopper for the user.
config.hpp
is relatively hardcore feature - you normally switch it on or off for the whole project; you can't have it on and off in one single cpp unit as I DO need in tests. That is why f.e. I have one special dedicatedtest/unittest/presentation/test_publisher_custom_config.cpp
source file.
So, IMHO we should not complicate things.
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.
Okay. You've convinced me.
ITransferIdMap
and internaldetail::ITransferIdStorage
interfaces.getIdFor
method.setIdFor
).