Backend & systems·Concurrency and coordination
you allow at most ten things through at once, not one, because the thing you are protecting is a capacity rather than a variable.
Semaphore
A counter-based primitive permitting up to N concurrent holders. It is the right tool for bounding concurrency against a limited resource — connections, in-flight calls to a downstream, memory-hungry jobs. A mutex is a semaphore of one, but reaching for a semaphore when you mean exclusivity makes the intent unclear.