public interface ICountDownLatch extends DistributedObject
ICountDownLatch is a cluster-wide synchronization aid that allows one or more threads to wait until a set of operations being performed in other threads completes.
There are a few differences compared to the
trySetCount(int)after a countdown has finished but not during an active count. This allows the same latch instance to be reused.
ICountDownLatch is accessed via
CPSubsystem.getCountDownLatch(String). It works on top of the Raft
consensus algorithm. It offers linearizability during crash failures and network
partitions. It is CP with respect to the CAP principle. If a network
partition occurs, it remains available on at most one side of the partition.
All of the API methods in the new CP
ICountDownLatch impl offer
the exactly-once execution semantics. For instance, even if
countDown() call is internally retried because of crashed
Hazelcast member, the counter value is decremented only once.
|Modifier and Type||Method and Description|
Causes the current thread to wait until the latch has counted down to zero, or an exception is thrown, or the specified waiting time elapses.
Decrements the count of the latch, releasing all waiting threads if the count reaches zero.
Returns the current count.
Sets the count to the given value if the current count is zero.
boolean await(long timeout, TimeUnit unit) throws InterruptedException
If the current count is zero then this method returns immediately
with the value
If the current count is greater than zero, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of five things happen:
If the current thread:
InterruptedExceptionis thrown and the current thread's interrupted status is cleared.
If the specified waiting time elapses then the value
is returned. If the time is less than or equal to zero, the method
will not wait at all.
timeout- the maximum time to wait
unit- the time unit of the
trueif the count reached zero,
falseif the waiting time elapsed before the count reached zero
InterruptedException- if the current thread is interrupted
IllegalStateException- if the Hazelcast instance is shutdown while waiting
NullPointerException- if unit is null
If the current count is greater than zero, then it is decremented. If the new count is zero:
boolean trySetCount(int count)
If count is not zero, then this method does nothing and returns
Copyright © 2020 Hazelcast, Inc.. All rights reserved.