Do flyweight patterns exist in coroutines?
For example, let's say I have 5 suspend methods that require a parameter, which can also be retrieved by a suspend method.
If I call two of them simultaneously, is there a way for me to have them wait on the same suspension?
One way of doing this would be to keep a map of keys to deferred values, where I assume that calling await twice will only run the logic once. Is there a better way of achieving that?
b
bdawg.io
09/28/2018, 3:56 AM
That's literally what you get by using
async
and then calling
await()
on the same deferred object
If you do a Lazy dispatched
async
you can spawn them all off immediately and then the