groostav
01/04/2017, 10:38 AMsuspend fun
along the lines of:
suspend fun <K, V> Cache<K, V>.cached(key: K, valueSupplier: suspend () -> V)
that has the properties:
- the first time its called, the caller is suspended, execution is started. When the execution is done, the entry is added to the cache, and also returned to the suspended caller
- the second time its called, regardless of whether that second time is before or after the previous computation has completed, it is suspended until the first callers result becomes available, at which point it is retrieved and returned to the suspended caller