what is the best way to simulate an arrayblockingq...
# coroutines
a
what is the best way to simulate an arrayblockingqueue/channel ? MutableSharedFlow? I want to have a place to put items in such that only 1 of my 64 coroutines receive them - simple use case - items come in via a blocking http server [i.e. will need runBlocking to call any suspend methods] - I want to add it to the queue and have the coroutines in the background fetch them in chunks if possible
z
That sounds like a use case for an actual channel.
a
Correct - I want to use a regular channel - but i keep reading flow preferred over channels
i
See Roman's recent post and the use case for channels as the mechanism for 'delivered only once': https://elizarov.medium.com/shared-flows-broadcast-channels-899b675e805c#49e3
☝️ 1
receiveAsFlow()
keeps the consuming side still using the flow APIs
z
If you’re implementing a worker pool like it sounds like you are, there’s probably no need to have Flow involved at all
a
perf thanks!