org.elasticsearch.common.util.concurrent.resource
Class BlockingAcquirableResource<T extends Releasable>

java.lang.Object
  extended by org.elasticsearch.common.util.concurrent.resource.BlockingAcquirableResource<T>
All Implemented Interfaces:
AcquirableResource<T>

public class BlockingAcquirableResource<T extends Releasable>
extends java.lang.Object
implements AcquirableResource<T>

A wrapper around a resource that can be released. Note, release should not be called directly on the resource itself.

Yea, I now, the fact that the resource itself is releasable basically means that users of this class should take care... .


Constructor Summary
BlockingAcquirableResource(T resource)
           
 
Method Summary
 boolean acquire()
          Acquires the resource, returning true if it was acquired.
 void forceClose()
          Forces the resource to be closed, regardless of the number of acquirers.
 void markForClose()
          Marks the resource to be closed.
 void release()
          Releases the resource, will close it if there are no more acquirers.
 T resource()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingAcquirableResource

public BlockingAcquirableResource(T resource)
Method Detail

resource

public T resource()
Specified by:
resource in interface AcquirableResource<T extends Releasable>

acquire

public boolean acquire()
Acquires the resource, returning true if it was acquired.

Specified by:
acquire in interface AcquirableResource<T extends Releasable>

release

public void release()
Releases the resource, will close it if there are no more acquirers.

Specified by:
release in interface AcquirableResource<T extends Releasable>

markForClose

public void markForClose()
Marks the resource to be closed. Will close it if there are no current acquires.

Specified by:
markForClose in interface AcquirableResource<T extends Releasable>

forceClose

public void forceClose()
Description copied from interface: AcquirableResource
Forces the resource to be closed, regardless of the number of acquirers.

Specified by:
forceClose in interface AcquirableResource<T extends Releasable>