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

new internal event functions with ownership handling (ownership used for linux implementation only) #1222

Merged
merged 8 commits into from
Oct 25, 2023

Conversation

rex-schilasky
Copy link
Contributor

@rex-schilasky rex-schilasky commented Oct 23, 2023

Description

Introducing ownership flag for named event creation.

Related issues

Fixes #1218

Cherry-pick to

  • 5.12 (current stable)

@rex-schilasky rex-schilasky changed the title Bugfix/event ownership added api new owner flag added to event creation by additional api functions (used on linux os only) Oct 23, 2023
@rex-schilasky rex-schilasky added bug Something isn't working 5.12.1 labels Oct 23, 2023
Copy link
Contributor

@KerstinKeller KerstinKeller left a comment

Choose a reason for hiding this comment

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

See my comments.
Also I wonder if we should deprecate the whole ecal event API and make it private for eCAL 6.
There is no reason for it being public. One can think of it as a different library / API, but it has no business in the higher level API.
Maybe this was due to testing purposes? But there are other ways to achieve the same.

Also, I don't quite understand why they need to be global functions in the first place. Why not objects, like you then have internally with CNamedEvent....


/**
* @brief Open a named event with ownership.
*
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment is wrong. However, do unnamed Events have ownership? How do unnamed events communicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is fixed ..

@@ -302,9 +321,10 @@ namespace eCAL
class CNamedEvent
{
public:
explicit CNamedEvent(const std::string& name_) :
explicit CNamedEvent(const std::string& name_, bool ownership_) :
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to change it, but I would like to make a remark. I strongly dislike the bool for ownership vs non-ownership.
This should be two different classed, e.g. OwnedNamedEvent and NonOwnedNamedEvent/WeakNamedEvent.
This has two advantages:
a) To everyone reading the code that is using the events, it's clear from the type, if the event is the owner / creator or not
b) You can use inheritance. You don't need to do stuff like if(m_owner) ... which makes code clearer and more readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, shouldn't the owner always create the event? In the code this is not tied together?

Copy link
Contributor Author

@rex-schilasky rex-schilasky Oct 23, 2023

Choose a reason for hiding this comment

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

I just wanted to "just fix the issue" and introduce as little change as possible. Let's redesign this in a separate issue.

The same for the creation. The behavior is now exact the same as before. The event is created by the first call of OpenEvent independently from the new ownership attribute. The ownership only plays a role in the destruction phase.

@@ -923,8 +919,6 @@ TEST(IO, ZeroPayloadMessageTCP)
}
#endif

#include <ecal/msg/string/publisher.h>
#include <ecal/msg/string/subscriber.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

These includes should be needed but maybe we can move them to the top?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These includes should be needed but maybe we can move them to the top?

They are there and have been there before ..

…ternal API (ecal_event_internal.h) to be fully API/ABI compatible again
@rex-schilasky rex-schilasky changed the title new owner flag added to event creation by additional api functions (used on linux os only) two new internal event functions with ownership handling (used on linux os only) Oct 25, 2023
@rex-schilasky rex-schilasky changed the title two new internal event functions with ownership handling (used on linux os only) new internal event functions with ownership handling (used on linux os only) Oct 25, 2023
@rex-schilasky rex-schilasky changed the title new internal event functions with ownership handling (used on linux os only) new internal event functions with ownership handling (ownership used for linux implementation only) Oct 25, 2023
Copy link
Contributor

@KerstinKeller KerstinKeller left a comment

Choose a reason for hiding this comment

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

I guess it's the easiest way to fix our problems for now.

@rex-schilasky rex-schilasky merged commit 3884ace into master Oct 25, 2023
14 checks passed
@rex-schilasky rex-schilasky deleted the bugfix/event_ownership_added_api branch October 25, 2023 16:26
@rex-schilasky
Copy link
Contributor Author

Tested with the following setup https://github.com/rex-schilasky/ecal_dynamic_pubsub_test

FlorianReimold pushed a commit that referenced this pull request Oct 26, 2023
FlorianReimold pushed a commit that referenced this pull request Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

broken pub/sub connection by dynamic recreation of a publisher or subscriber
2 participants