Skip to content
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

Merged

Conversation

budrus
Copy link
Contributor

@budrus budrus commented Apr 8, 2020

No description provided.

Poehnl Michael (CC-AD/ESW1) added 6 commits April 4, 2020 23:23
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]>
Copy link
Contributor

@mossmaurice mossmaurice left a 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

Comment on lines -34 to -35
/// 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.
Copy link
Contributor

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 :-)

Copy link
Member

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 ;)

Comment on lines -32 to -33
struct ChunkQueueData;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Comment on lines 15 to 16
#ifndef IOX_POSH_POPO_CHUNK_RECEIVER_HPP_
#define IOX_POSH_POPO_CHUNK_RECEIVER_HPP_
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines 15 to 16
#ifndef IOX_POSH_POPO_CHUNK_RECEIVER_DATA_HPP_
#define IOX_POSH_POPO_CHUNK_RECEIVER_DATA_HPP_
Copy link
Contributor

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?

Copy link
Contributor Author

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_

Copy link
Contributor Author

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

Comment on lines +160 to +161
// 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)
Copy link
Contributor

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())
Copy link
Contributor

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.

Copy link
Contributor Author

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().

Copy link
Contributor

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(
Copy link
Contributor

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 )

Copy link
Contributor Author

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

Copy link
Contributor

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.

Comment on lines 67 to 74
class ChunkReceiver_test : public ChunkReceiver_testBase
{
public:
ChunkReceiver_test()
: ChunkReceiver_testBase()
{
}
};
Copy link
Contributor

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?

Copy link
Contributor Author

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..

@budrus
Copy link
Contributor Author

budrus commented Apr 14, 2020

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

oopsie, I thought I could swear that I had a green build. Time for the github actions like in the rmw_iceoryx

Poehnl Michael (CC-AD/ESW1) added 3 commits April 14, 2020 20:37
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]>
@budrus budrus requested a review from mossmaurice April 14, 2020 20:48
Poehnl Michael (CC-AD/ESW1) added 3 commits April 15, 2020 15:30
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]>
Copy link
Contributor

@mossmaurice mossmaurice left a 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 and optional variables to maybe* e.g. maybeChunkHeader

Comment on lines +75 to +76
source/popo/building_blocks/chunk_queue_pusher.cpp
source/popo/building_blocks/chunk_queue_popper.cpp
Copy link
Contributor

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!

Comment on lines -71 to +80
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)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@budrus
Copy link
Contributor Author

budrus commented Apr 21, 2020

* `PosixShmMemoryProvider_Test.CreateMemory` test is failing on my machine. It's not related to the changes, isn't it?

Fine on my side. Also no changes there

Signed-off-by: Poehnl Michael (CC-AD/ESW1) <[email protected]>
mossmaurice
mossmaurice previously approved these changes May 6, 2020
Comment on lines -34 to -35
/// 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.
Copy link
Member

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;
Copy link
Member

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?

Copy link
Contributor

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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

@mossmaurice mossmaurice merged commit 246085a into eclipse-iceoryx:master May 13, 2020
@mossmaurice mossmaurice linked an issue May 13, 2020 that may be closed by this pull request
13 tasks
@budrus budrus deleted the iox-#25-chunk-receiver-building-block branch May 13, 2020 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for n:m communciation (multiple senders on a topic / CaProID)
3 participants