call method

bool call(
  1. VoidCallback callback, [
  2. int tokens = 1
])

Execute callback if token is available, otherwise do nothing.

Implementation

bool call(VoidCallback callback, [int tokens = 1]) {
  if (tryAcquire(tokens)) {
    callback();
    return true;
  }
  return false;
}