com.hazelcast.core
Interface Semaphore

All Superinterfaces:
Instance

public interface Semaphore
extends Instance


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.hazelcast.core.Instance
Instance.InstanceType
 
Method Summary
 void acquire()
          Acquires a permit from this semaphore, blocking until one is available, or the thread is interrupted.
 void acquire(int permits)
          Acquires the given number of permits from this semaphore, blocking until all are available, or the thread is interrupted.
 void acquireUninterruptibly()
          Acquires a permit from this semaphore, blocking until one is available.
 void acquireUninterruptibly(int permits)
          Acquires the given number of permits from this semaphore, blocking until all are available.
 int availablePermits()
          Returns the current number of permits available in this semaphore.
 int drainPermits()
          Acquires and returns all permits that are immediately available.
 void release()
          Releases a permit, returning it to the semaphore.
 void release(int permits)
          Releases the given number of permits, returning them to the semaphore.
 boolean tryAcquire()
          Acquires a permit from this semaphore, only if one is available at the time of invocation.
 boolean tryAcquire(int permits)
          Acquires the given number of permits from this semaphore, only if all are available at the time of invocation.
 boolean tryAcquire(int permits, long timeout, TimeUnit unit)
          Acquires the given number of permits from this semaphore, if all become available within the given waiting time and the current thread has not been interrupted.
 boolean tryAcquire(long timeout, TimeUnit unit)
          Acquires a permit from this semaphore, if one becomes available within the given waiting time and the current thread has not been interrupted.
 
Methods inherited from interface com.hazelcast.core.Instance
destroy, getId, getInstanceType
 

Method Detail

acquire

void acquire()
             throws InterruptedException
Acquires a permit from this semaphore, blocking until one is available, or the thread is interrupted.

Throws:
InterruptedException

acquireUninterruptibly

void acquireUninterruptibly()
Acquires a permit from this semaphore, blocking until one is available.


tryAcquire

boolean tryAcquire()
Acquires a permit from this semaphore, only if one is available at the time of invocation.


tryAcquire

boolean tryAcquire(long timeout,
                   TimeUnit unit)
Acquires a permit from this semaphore, if one becomes available within the given waiting time and the current thread has not been interrupted.

Parameters:
timeout -
unit -
Returns:

release

void release()
Releases a permit, returning it to the semaphore.


acquire

void acquire(int permits)
             throws InterruptedException
Acquires the given number of permits from this semaphore, blocking until all are available, or the thread is interrupted.

Parameters:
permits -
Throws:
InterruptedException

acquireUninterruptibly

void acquireUninterruptibly(int permits)
Acquires the given number of permits from this semaphore, blocking until all are available.

Parameters:
permits -

tryAcquire

boolean tryAcquire(int permits)
Acquires the given number of permits from this semaphore, only if all are available at the time of invocation.

Parameters:
permits -
Returns:

tryAcquire

boolean tryAcquire(int permits,
                   long timeout,
                   TimeUnit unit)
Acquires the given number of permits from this semaphore, if all become available within the given waiting time and the current thread has not been interrupted.

Parameters:
permits -
timeout -
unit -
Returns:

release

void release(int permits)
Releases the given number of permits, returning them to the semaphore.

Parameters:
permits -

availablePermits

int availablePermits()
Returns the current number of permits available in this semaphore.

Returns:
the number of permits available in this semaphore

drainPermits

int drainPermits()
Acquires and returns all permits that are immediately available.

Returns:
the number of permits acquired


Copyright .9.3.1; 2008-2011 Hazel Ltd. All Rights Reserved.