class PendingWorkerCounter {

	int decreaseAndGet(final WorkerResourceSpec workerResourceSpec) {
		final Integer newValue = pendingWorkerNums.compute(
				Preconditions.checkNotNull(workerResourceSpec),
				(ignored, num) -> {
					Preconditions.checkState(num != null && num > 0,
							"Cannot decrease, no pending worker of spec %s.", workerResourceSpec);
					return num == 1 ? null : num - 1;
				});
		return newValue != null ? newValue : 0;
	}

	  PendingWorkerCounter();

}