-spec with(resource(), fun(() -> A)) -> A.
Run an operation with an acquired resource semaphore.
Warning: don’t abuse this API.
It is only useful for calling external commands,
like calling gcc or git or heavy computations.
There are some limitations to avoid deadlocks: