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

Add way to de-duplicate function calls #1097

Open
chrisbanes opened this issue Apr 15, 2019 · 3 comments
Open

Add way to de-duplicate function calls #1097

chrisbanes opened this issue Apr 15, 2019 · 3 comments

Comments

@chrisbanes
Copy link

chrisbanes commented Apr 15, 2019

I currently have a number of places where I request a specific URL. It would be nice if any concurrent requests would be de-duplicated so that any requests which are started while one is already in progress, joins the first and receives the same result.

I imagine that this would be similar to Go's singleflight: a collection wrapper around a Mutex, keyed on a string.

@elizarov
Copy link
Contributor

Does it really has to be keyed by a string? We are not in Go, you know, we can do much better.

@chrisbanes
Copy link
Author

Yeah agreed, although I do like the simplicity of a string. Using an inline class Key(val k: String) would work just as well though.

@LouisCAD
Copy link
Contributor

I have to link this gist from @objcode, because it might help folks having this call de-duplicating use case: https://gist.github.com/objcode/7ab4e7b1df8acd88696cb0ccecad16f7#file-concurrencyhelpers-kt-L162-L339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants