sync icon indicating copy to clipboard operation
sync copied to clipboard

singleflight: add per caller function

Open costela opened this issue 3 years ago • 5 comments

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?

costela avatar Oct 19 '22 18:10 costela

This PR (HEAD: 8fa636b7549ef62d9eb0218d8b59960510ed31f2) 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 avatar Oct 19 '22 19:10 gopherbot

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 avatar Oct 20 '22 15:10 gopherbot

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!

gopherbot avatar Oct 20 '22 15:10 gopherbot

Moved to draft while proposal is active.

costela avatar Oct 20 '22 16:10 costela

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!

gopherbot avatar Oct 20 '22 16:10 gopherbot