tryWithPermit
Runs block while holding a permit only if one is available, returning null otherwise.
The permit attempt uses Semaphore.tryAcquire, so this function never waits and null means no permit was free. The permit is released even when block throws.
Cancellation: this function does not suspend and performs no cancellation checks; a non-suspending block runs to completion once started.