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

offer mutable access to containers through handles #494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petrosagg
Copy link
Contributor

This PR refactors a pattern that is pervasive to pretty much every single timely operator into an easier to use input handle method that also reduces the boilerplate code operator authors need to write.

The pattern is receiving a RefOrMut container from a handle and immediately swapping it with a local container in order to gain mutable access. In this repo all but one operators exhibited this pattern and associated boilerplate.

pub fn for_each<F: FnMut(CapabilityRef<T>, RefOrMut<D>)>(&mut self, mut logic: F) {
let mut logging = self.logging.take();
while let Some((cap, data)) = self.next() {
logging.as_mut().map(|l| l.log(crate::logging::GuardedMessageEvent { is_start: true }));
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 can make the next and next_mut methods do this logging if desired. It wasn't clear to me if the current thinking was more in line with next that didn't log or with for_each that did log. Let me know if I got this the other way around

This PR refactors a pattern that is pervasive to pretty much every
single timely operator into an easier to use input handle method that
also reduces the boilerplate code operator authors need to write.

The pattern is receiving a `RefOrMut` container from a handle and
immediately swapping it with a local container in order to gain mutable
access. In this repo all but one operators exhibited this pattern and
associated boilerplate.

Signed-off-by: Petros Angelatos <[email protected]>
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.

1 participant