Skip to content

Conversation

@shsms
Copy link
Contributor

@shsms shsms commented Oct 8, 2024

This is an alternative to the selected_from method.

@shsms shsms requested a review from a team as a code owner October 8, 2024 09:53
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) labels Oct 8, 2024
@shsms shsms requested review from llucax and removed request for ela-kotulska-frequenz October 8, 2024 09:53
@github-actions github-actions bot added the part:docs Affects the documentation label Oct 8, 2024
@shsms
Copy link
Contributor Author

shsms commented Oct 8, 2024

Other naming options: matches, matches_selected

Copy link
Contributor

@llucax llucax left a comment

Choose a reason for hiding this comment

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

OK, so the issue we had with TypeGuard as a member method was not it being a member method but about applying the type guard to self, this is why we can't do selected.source(receiver), because we want to narrow selected, not receiver, but when used as a member the variable to narrow is the second argument, not self.

So receiver.is_selected(selected) works and will narrow selected. OK. I don't like the fact that now part of select()is implemented inReceiverunless we have a considerable improvement in how the code is read, andreceiver.is_selected(selected)doesn't read much better thanselected_from(selected, receiver)`.

But maybe something like receiver.is_source_of(selected) could work. What do you think?

@shsms shsms force-pushed the selected branch 2 times, most recently from fc7064a to 7005e83 Compare October 31, 2024 11:42
@shsms shsms changed the title Add a Receiver.is_selected method Add a Receiver.matches method Oct 31, 2024
@shsms shsms changed the title Add a Receiver.matches method Add a Receiver.triggered method Oct 31, 2024
@shsms shsms requested a review from llucax October 31, 2024 13:14
@llucax llucax added this to the v1.3.0 milestone Nov 1, 2024
shsms added 5 commits November 5, 2024 15:03
This is an alternative for the `selected_from` method and could
eventually replace it.

Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
@shsms shsms added this pull request to the merge queue Nov 5, 2024
Merged via the queue into frequenz-floss:v1.x.x with commit 486d1be Nov 5, 2024
14 checks passed
@shsms shsms deleted the selected branch November 5, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:core Affects the core types (`Sender`, `Receiver`, exceptions, etc.) part:docs Affects the documentation part:synchronization Affects the synchronization of multiple sources (`select`, `merge`) part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants