Hi, is `Semaphore` meant to be at application laye...
# coroutines
u
Hi, is
Semaphore
meant to be at application layer? My case it to enforce only 1 caller of synchronization at a time
l
If you only want one caller at a time and you know it's not going to change to another number, you want to use
Mutex
instead.
u
right, it will work, but im confused if there should be such api used in between my business logic which syncing basically is
but I guess people use Channels for data flow, and theyre also a coroutine primitive, so ..
may I ask, difference with coroutine Mutex or Semaphore is that it gets suspended on that point, and thread is freed to do others stuff -- as usual, right?
l
There's multiple differences. Semaphore can allow a given number of acquirers that is greater than one for example. The docs are good at explaining each of these.
u
I know what those two do, I only meant them as a coroutine api, vs their thread equivalent
l
Blocking threads is more wasteful, and that's the only thing the non coroutines-friendly version can do.