use of com.hazelcast.concurrent.semaphore.operations.AcquireOperation in project hazelcast by hazelcast.
the class SemaphoreProxy method acquire.
@Override
public void acquire(int permits) throws InterruptedException {
checkNotNegative(permits, "permits can't be negative");
try {
Operation operation = new AcquireOperation(name, permits, -1).setPartitionId(partitionId);
InternalCompletableFuture<Object> future = invokeOnPartition(operation);
future.get();
} catch (Throwable t) {
throw rethrowAllowInterrupted(t);
}
}
use of com.hazelcast.concurrent.semaphore.operations.AcquireOperation in project hazelcast by hazelcast.
the class SemaphoreProxy method tryAcquire.
@Override
public boolean tryAcquire(int permits, long timeout, TimeUnit unit) throws InterruptedException {
checkNotNegative(permits, "permits can't be negative");
try {
Operation operation = new AcquireOperation(name, permits, unit.toMillis(timeout)).setPartitionId(partitionId);
Future<Boolean> future = invokeOnPartition(operation);
return future.get();
} catch (Throwable t) {
throw rethrowAllowInterrupted(t);
}
}
Aggregations