-
Notifications
You must be signed in to change notification settings - Fork 403
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 #25 chunk receiver building block #84
Iox #25 chunk receiver building block #84
Conversation
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
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.
The target posh_moduletests
fails to build:
/home/foo/repos/iceoryx/iceoryx_posh/test/moduletests/test_popo_chunk_sender.cpp:77:106: error: wrong number of template arguments (2, should be 1) using ChunkDistributor_t = iox::popo::ChunkDistributor<MAX_NUMBER_QUEUES, iox::popo::ThreadSafePolicy>;
Please fix the test
/// When different threads operate on it (e.g. application sends chunks and RouDi adds and removes queues), | ||
/// a locking policy must be used that ensures consistent data in the ChunkDistributorData. |
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.
Keep fighting the trailing whitespaces :-)
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.
doesn't your IDE automatically remove trailing whitespaces ... me starting IDE war and running away ;)
struct ChunkQueueData; | ||
|
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.
Nice catch!
#ifndef IOX_POSH_POPO_CHUNK_RECEIVER_HPP_ | ||
#define IOX_POSH_POPO_CHUNK_RECEIVER_HPP_ |
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.
As we decided to switch to include guards (#30), we can keep them here. Isn't the #define IOX_CHUNK_RECEIVER_HPP
enough to avoid ambiguity?
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 thought I use them here as we decided to use them again. But we haven't defined a rule for them yet, or?
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.
Nope there's no rule yet. Let's define it with #30
/// disappears | ||
/// @return optional that has a new chunk header or no value if there are no new chunks in the underlying queue, | ||
/// ChunkReceiverError on error | ||
cxx::expected<cxx::optional<const mepoo::ChunkHeader*>, ChunkReceiverError> get() noexcept; |
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.
Why the optional
inside an expected
? Isn't it enough to either provide a ChunkHeader pointer or an ChunkReceiverError
?
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.
No, if there is no new chunk, you will get an empty optional without an error. Like a pop on an empty FiFo
#ifndef IOX_POSH_POPO_CHUNK_RECEIVER_DATA_HPP_ | ||
#define IOX_POSH_POPO_CHUNK_RECEIVER_DATA_HPP_ |
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.
IOX_CHUNK_RECEIVER_DATA_HPP
?
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.
no rule bro, so my decision ;-)
Shall we have at least the component name in it. Maybe threre will be modules with same names in different components. So maybe IOX_POPO_CHUNK_RECEIVER_DATA_HPP_
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'll give that a try
// if the seqence number in the chunk info is set by the user, we still increment the internal one as this | ||
// might be needed by midddleware spcific evaluation (like in introspection) |
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.
Thanks for clearing this up!
else | ||
{ | ||
// drop the chunk if one is returned by a safe overflow | ||
if ((*pushRet).has_value()) |
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'd prefer to call pushRet.get_value()
instead of operator*()
. Makes it more readable for me.
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.
hmmm, for my not. (pushRet.get_value()).has_value()? But yes optional and expected allow a lot of different flavors. I prefer has_value() and has_error() and not the bool operators, for better readability. But I like * operator instead of get_value().
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 have no hard feelings about this. My eye just notices .get_value()
easier than *
;-)
{ | ||
ChunkQueueData::ChunkTuple chunkTupleIn(chunk.releaseWithRelativePtr()); | ||
|
||
return !getMembers() | ||
->m_queue.push(chunkTupleIn) | ||
.on_success( |
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.
Why not staying in the functional world? You can concatenate the success and error case easily ;-) m_queue.push(foo).on_success( GoodCallable ).on_error( BadCallable )
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 have to talk about std::function one day... Could become a heap and ASIL D compiler support topic
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 had function_ref
on my mind in the last few months. Created issue #86. IMHO we should be able to replace all std::function
occurrences with it.
class ChunkReceiver_test : public ChunkReceiver_testBase | ||
{ | ||
public: | ||
ChunkReceiver_test() | ||
: ChunkReceiver_testBase() | ||
{ | ||
} | ||
}; |
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.
Why is this additional derivation necessary?
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.
Too much copy and waste from other test I guess..
oopsie, I thought I could swear that I had a green build. Time for the github actions like in the rmw_iceoryx |
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
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.
PosixShmMemoryProvider_Test.CreateMemory
test is failing on my machine. It's not related to the changes, isn't it?- I think it would be nice to change all the
expected
andoptional
variables tomaybe*
e.g.maybeChunkHeader
source/popo/building_blocks/chunk_queue_pusher.cpp | ||
source/popo/building_blocks/chunk_queue_popper.cpp |
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.
Nice to have two interfaces!
auto override = | ||
auto notskipped = | ||
m_fifo.template get_at_index<static_cast<uint64_t>(VariantQueueTypes::SoFi_SingleProducerSingleConsumer)>() | ||
->push(value, overriddenValue); | ||
if (override) | ||
if (notskipped) | ||
{ | ||
ret = success<optional<ValueType>>(optional<ValueType>(std::move(overriddenValue))); | ||
ret = success<optional<ValueType>>(nullopt_t()); | ||
} | ||
else | ||
{ | ||
ret = success<optional<ValueType>>(nullopt_t()); | ||
ret = success<optional<ValueType>>(optional<ValueType>(std::move(overriddenValue))); |
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.
Good catch!
Fine on my side. Also no changes there |
Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
/// When different threads operate on it (e.g. application sends chunks and RouDi adds and removes queues), | ||
/// a locking policy must be used that ensures consistent data in the ChunkDistributorData. |
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.
doesn't your IDE automatically remove trailing whitespaces ... me starting IDE war and running away ;)
|
||
ChunkDistributor(MemberType_t* const chunkDistrubutorDataPtr) noexcept; | ||
ChunkDistributor(cxx::not_null<MemberType_t* const> chunkDistrubutorDataPtr) noexcept; |
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.
@MatthiasKillat mentioned to use a reference instead of a cxx::not_null. What do you think?
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.
Let's stick to a pointer with cxx::not_null
for now.
|
||
ChunkDistributor(MemberType_t* const chunkDistrubutorDataPtr) noexcept; | ||
ChunkDistributor(cxx::not_null<MemberType_t* const> chunkDistrubutorDataPtr) noexcept; | ||
|
||
ChunkDistributor(const ChunkDistributor& other) = delete; | ||
ChunkDistributor& operator=(const ChunkDistributor&) = delete; |
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.
aaargh, I cannot comment on the move assignment operator. With MemberType_t* const m_chunkDistrubutorDataPtr;
and = default
the move assignment operator is implicitly deleted, since it's not possible to assign something to a * const
@@ -110,10 +116,12 @@ class ChunkDistributor | |||
MemberType_t* getMembers() noexcept; | |||
|
|||
private: | |||
MemberType_t* m_chunkDistrubutorDataPtr{nullptr}; | |||
MemberType_t* const m_chunkDistrubutorDataPtr; |
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.
this implicitly deletes the move assignment operator
@@ -94,8 +84,10 @@ class ChunkQueue | |||
MemberType_t* getMembers() noexcept; | |||
|
|||
private: | |||
MemberType_t* m_chunkQueueDataPtr{nullptr}; | |||
MemberType_t* const m_chunkQueueDataPtr; |
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.
again, the * const
implicitly deletes the defaulted move assignment operator
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.
OK, so the best we can do to be moveable and the better API would then be a reference in the c'tor and the non const pointer as member. Most of these objects will be created with a ...Data object that was created before and can then be passed as reference
@@ -108,10 +108,13 @@ TEST_F(VariantQueue_test, handlesOverflow) | |||
{ | |||
PerformTestForQueueTypes([](uint64_t typeID) { | |||
VariantQueue<int, 2> sut(static_cast<VariantQueueTypes>(typeID)); | |||
// current SOFI can hold capacity +1 values, so push some more to ensure overflow |
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 should fix this surprising SOFI behaviour
…ut error Signed-off-by: Kraus Mathias (CC-AD/ESW1) <[email protected]>
Signed-off-by: Kraus Mathias (CC-AD/ESW1) <[email protected]>
No description provided.