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

Construct event channel outside of Context #3421

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

link2xt
Copy link
Collaborator

@link2xt link2xt commented Jun 11, 2022

This allows account manager to construct a single event channel and
inject it into all created contexts instead of aggregating events from
separate event emitters.

#skip-changelog this is a refactoring

This allows account manager to construct a single event channel and
inject it into all created contexts instead of aggregating events from
separate event emitters.
@link2xt link2xt force-pushed the link2xt/event-channel-refactoring branch 3 times, most recently from 689eddf to 7402f74 Compare June 11, 2022 16:22
@link2xt link2xt requested a review from Hocuri June 11, 2022 18:04
@link2xt link2xt force-pushed the link2xt/event-channel-refactoring branch 2 times, most recently from 56acd86 to d55ccfd Compare June 13, 2022 20:24
Copy link
Member

@flub flub left a comment

Choose a reason for hiding this comment

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

Much better indeed.

All this cloning of the Receivers is a bit on the scary side, but really that problem already exists because of get_emitter so nothing worse there. But maybe one day we'll actually ensure there can be only one emitter.

@link2xt
Copy link
Collaborator Author

link2xt commented Jun 16, 2022

All this cloning of the Receivers is a bit on the scary side, but really that problem already exists because of get_emitter so nothing worse there. But maybe one day we'll actually ensure there can be only one emitter.

This can be ensured by:

  1. Making Events non-cloneable again.
  2. Making it impossible to extract Recevier clone from Events. This means there will be no more dedicated EventEmitter, Events itself becomes the event emitter.
  3. Passing Events by reference to Context::new() so it can clone sender from it.

This is possible to do in #3422. On C side user will create dc_event_emitter_t, then pass it to dc_context_new.

@link2xt link2xt force-pushed the link2xt/event-channel-refactoring branch from d55ccfd to 0ed3480 Compare June 16, 2022 16:43
@link2xt link2xt merged commit 0ed3480 into master Jun 16, 2022
@link2xt link2xt deleted the link2xt/event-channel-refactoring branch June 16, 2022 16:44
@link2xt link2xt mentioned this pull request Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants