Counted semaphore primitive for generator flow-control.