https://kotlinlang.org logo
Title
a

ansman

04/17/2019, 1:50 PM
There is no counting semaphore in coroutines yet right? Only
Mutex
?
v

Vsevolod Tolstopyatov [JB]

04/17/2019, 1:54 PM
Not yet, but it is in work, PR #1101
💯 2
👏 2
a

ansman

04/17/2019, 1:54 PM
Great, thanks!
As a FYI I’m trying to limit concurrency due to memory constraints. Was planning on using a semaphore for that
I could use a worker pool but for now that would be overkill
v

Vsevolod Tolstopyatov [JB]

04/17/2019, 2:02 PM
As a temporary workaround you can use
Channel<Unit>(permits)
as a semaphore
a

ansman

04/17/2019, 2:02 PM
Right. And it would never block when putting a permit back since there doesn’t exist more permits than the buffer size
w

withoutclass

04/17/2019, 2:13 PM
You can also limit work using the fan-out method