What if you just want to limit how many things you can have or can be done? This episode will explain another side of the semaphore sometimes called a counting semaphore.
When you’re using semaphores, you have a way to wait on the availability of something, but you also really need to have some way to inform the other side when there’s more room to add something. If you really don’t have a need for some other code to run during this, then why have a whole other side in the first place? In this case, all you really need to do is have your thread signal the same semaphore that it waited on when it’s done so that some other thread can have a turn.
Just be aware that this isn’t the original intention of semaphores and that you might be overlooking an opportunity to add some extra flexibility to your code by going with a simpler design. And you might even find that what at first seemed like the simpler design just led to more complexities as you try to maintain the “simple” design.
If you want to use semaphores like this, then the method names up and down make more sense to me than signal and wait.