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

Consider making "event_source::operator<<" transaction wrapper #137

Open
YarikTH opened this issue Sep 10, 2023 · 1 comment
Open

Consider making "event_source::operator<<" transaction wrapper #137

YarikTH opened this issue Sep 10, 2023 · 1 comment

Comments

@YarikTH
Copy link
Owner

YarikTH commented Sep 10, 2023

Description

Currently operator<< is just a fancy way on writing src.emit(...);

Following code just emits 3 events in separate propagation turns.

ureact::event_source src = make_source<int>();
src << 1 << 2 << 3;

But it can be changed to do so atomically in a single turn. To do so "event_source::operator<<" should return some RAII proxy that starts transaction in the constructor, finishes it in the destructor and provides it's own operator<< to emit further events.

It would be a breaking change and I'm not sure if it is needed at all. But at the first glance it looks like a neat feature.

@YarikTH
Copy link
Owner Author

YarikTH commented Sep 10, 2023

There is additional place where it can be considered - event_source::begin()

ureact::event_source src = make_source<int>();
std::copy( v.begin(), v.end(), src.begin() );

Currently it emits each event in a separate turn, but such iterator can as well perform transaction. Unlike operator<< this approach doesn't have reserve syntax to send events separately, so other method and iterator might be needed.

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

No branches or pull requests

1 participant