I realize this would be better modeled using `wait` and `notify`, but unfortunately doing so would not work as we already use that lock in other places. So instead of done this little trick to make a semaphore act as a wait()