com.hazelcast.concurrent.countdownlatch
Class CountDownLatchProxy

java.lang.Object
  extended by com.hazelcast.spi.AbstractDistributedObject<CountDownLatchService>
      extended by com.hazelcast.concurrent.countdownlatch.CountDownLatchProxy
All Implemented Interfaces:
DistributedObject, ICountDownLatch

public class CountDownLatchProxy
extends AbstractDistributedObject<CountDownLatchService>
implements ICountDownLatch


Field Summary
 
Fields inherited from class com.hazelcast.spi.AbstractDistributedObject
PARTITIONING_STRATEGY
 
Constructor Summary
CountDownLatchProxy(String name, NodeEngine nodeEngine)
           
 
Method Summary
 boolean await(long timeout, TimeUnit unit)
          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.
 void countDown()
          Decrements the count of the latch, releasing all waiting threads if the count reaches zero.
 int getCount()
          Returns the current count.
 String getName()
          Returns the unique name for this DistributedObject.
 String getServiceName()
          Returns the service name for this object.
 String toString()
           
 boolean trySetCount(int count)
          Sets the count to the given value if the current count is zero.
 
Methods inherited from class com.hazelcast.spi.AbstractDistributedObject
destroy, equals, getId, getNameAsPartitionAwareData, getNodeEngine, getPartitionKey, getService, hashCode, invalidate, postDestroy, throwNotActiveException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getId, getPartitionKey
 

Constructor Detail

CountDownLatchProxy

public CountDownLatchProxy(String name,
                           NodeEngine nodeEngine)
Method Detail

getName

public String getName()
Description copied from interface: DistributedObject
Returns the unique name for this DistributedObject. The returned value will never be null.

Specified by:
getName in interface DistributedObject
Returns:
the unique name for this object.

await

public boolean await(long timeout,
                     TimeUnit unit)
              throws InterruptedException
Description copied from interface: ICountDownLatch
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.

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 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.

Specified by:
await in interface ICountDownLatch
Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if the count reached zero, false if the waiting time elapsed before the count reached zero
Throws:
InterruptedException - if the current thread is interrupted

countDown

public void countDown()
Description copied from interface: ICountDownLatch
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.

Specified by:
countDown in interface ICountDownLatch

getCount

public int getCount()
Description copied from interface: ICountDownLatch
Returns the current count.

Specified by:
getCount in interface ICountDownLatch
Returns:
the current count

trySetCount

public boolean trySetCount(int count)
Description copied from interface: ICountDownLatch
Sets the count to the given value if the current count is zero.

If count is not zero, then this method does nothing and returns false.

Specified by:
trySetCount in interface ICountDownLatch
Parameters:
count - the number of times ICountDownLatch.countDown() must be invoked before threads can pass through ICountDownLatch.await(long, java.util.concurrent.TimeUnit)
Returns:
true if the new count was set, false if the current count is not zero

getServiceName

public String getServiceName()
Description copied from interface: DistributedObject
Returns the service name for this object.

Specified by:
getServiceName in interface DistributedObject
Specified by:
getServiceName in class AbstractDistributedObject<CountDownLatchService>
Returns:
the service name for this object.

toString

public String toString()
Overrides:
toString in class AbstractDistributedObject<CountDownLatchService>


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.