I'm writing a class that will handle thread synchronisation.
It would have a begin method which would increment a counter and an end method that would de-increment a counter. It'll have another method which will block while the counter is not zero, then perform an action while holding the lock.
Its a bit like the opposite of a semaphore, because it's unlocked at zero, and can get locked multiple times, only becoming unlocked again once it's been unlocked an equal number of times.
Is there a name for this pattern?
It's a class based on the accepted answer of my question here