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

singleflight: add per caller function #20

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

Conversation

costela
Copy link

@costela costela commented Oct 19, 2022

This PR is an alternative to the proposal in #9, inspired by @bcmills' comment.

The general idea is to add a second function argument to Do, which is guaranteed to be called by all goroutines waiting on a singleflight before the singleflighted call returns. It complements the existing function argument so that writing code that must be called in all cases becomes trivial.

Some refactoring to reduce code duplication could also be done, but I wanted to get some first working version out to kickstart a discussion.

Names are of course up for bikeshedding.

WDYT?

@gopherbot
Copy link

This PR (HEAD: 8fa636b) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/444215 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

Message from Bryan Mills:

Patch Set 1: Hold+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/444215.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Leo Antunes:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/444215.
After addressing review feedback, remember to publish your drafts!

@costela
Copy link
Author

costela commented Oct 20, 2022

Moved to draft while proposal is active.

@gopherbot
Copy link

Message from Leo Antunes:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/444215.
After addressing review feedback, remember to publish your drafts!

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