In reply to timag:
It really doesn’t make much sense to use semaphores in functions. Yes you can call try_get() from another function. But what if it returns false, then what do you do? You can’t keep calling it until it returns true because you get into a infinite zero-delay loop.