Hazelcast C++ Client
|
ICountDownLatch is a backed-up distributed alternative to the java.util.concurrent.CountDownLatch java.util.concurrent.CountDownLatch. More...
#include <ICountDownLatch.h>
Public Member Functions | |
bool | await (long timeoutInMillis) |
Causes the current thread to wait until the latch has counted down to zero, an exception is thrown, or the specified waiting time elapses. More... | |
void | countDown () |
Decrements the count of the latch, releasing all waiting threads if the count reaches zero. More... | |
int | getCount () |
Returns the current count. More... | |
bool | trySetCount (int count) |
Sets the count to the given value if the current count is zero. More... | |
Friends | |
class | impl::HazelcastClientInstanceImpl |
ICountDownLatch is a backed-up distributed alternative to the java.util.concurrent.CountDownLatch java.util.concurrent.CountDownLatch.
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 ICountDownLatch :
bool hazelcast::client::ICountDownLatch::await | ( | long | timeoutInMillis | ) |
Causes the current thread to wait until the latch has counted down to zero, an exception is thrown, or the specified waiting time elapses.
If the current count is zero then this method returns immediately with the value true.
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 count reaches zero then the method returns with the value true.
If the countdown owner becomes disconnected while waiting then MemberLeftException will be thrown.
If the current thread:
then InterruptedException is thrown and the current thread's interrupted status is cleared.
If the specified waiting time elapses then the value false is returned. If the time is less than or equal to zero, the method will not wait at all.
timeoutInMillis | the maximum time to wait |
void hazelcast::client::ICountDownLatch::countDown | ( | ) |
Decrements the count of the latch, releasing all waiting threads if the count reaches zero.
If the current count is greater than zero then it is decremented. If the new count is zero:
If the current count equals zero then nothing happens.
int hazelcast::client::ICountDownLatch::getCount | ( | ) |
Returns the current count.
bool hazelcast::client::ICountDownLatch::trySetCount | ( | int | count | ) |
Sets the count to the given value if the current count is zero.
The calling cluster member becomes the owner of the countdown and is responsible for staying connected to the cluster until the count reaches zero. If the owner becomes disconnected before the count reaches zero:
If count is not zero then this method does nothing and returns false.
IllegalArgumentException | if count is negative |