Anyway, here is a work-around for you: 1. Create a...
# coroutines
e
Anyway, here is a work-around for you: 1. Create a buffered channel with
n
elements of any type. Let's use `Unit`:
val chan = Channel<Unit>(n)
2. Put
n
elements there intially. These are your permits:
repeat(n) { chan.offer(Unit) }
3. When you need a permit receive it from the channel:
chan.receive()
4. When you done working, send permit back to channel:
chan.send(Unit)