just out of curiosity.. are there plans to impleme...
# coroutines
d
just out of curiosity.. are there plans to implement suspending semaphores like we currently have suspending mutexes? You can make a very basic one right now by sending/receiving from a channel with a finite capacity - but then there's also stuff like acquiring n semaphores, and optimizing by disabling fairness https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html
g
Do you have some particular use case for suspending semaphore?
d
I'm benchmarking an application right now which involves sending concurrent requests to a server and measuring throughput. However, the application doesn't enjoy having too many concurrent requests open. So I try to send x requests concurrently using coroutines and I want most of those coroutines to suspend until it can acquire 1 out of 500 "semaphores", giving it permission to open a request
v
We don’t have such plans, our priority is to add more high-level features now (typed actors, cold streams, proper exception handling etc.). For your case, probably something like batch actor will help:
Copy code
val actor = workerPool(parallelism = n) { myRequestSendingActor() }

actor.request() // <- may be processed in up to n threads
That’s in our roadmap 🙂
👍 1