Kotlinx.coroutines: Add way to de-duplicate function calls

Created on 15 Apr 2019  路  2Comments  路  Source: Kotlin/kotlinx.coroutines

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.

enhancement

Most helpful comment

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

All 2 comments

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaozinfs picture jaozinfs  路  3Comments

mttmllns picture mttmllns  路  3Comments

elizarov picture elizarov  路  3Comments

mhernand40 picture mhernand40  路  3Comments

ScottPierce picture ScottPierce  路  3Comments