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

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

public class NonBlockingAcquirableResource<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
NonBlockingAcquirableResource(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 and it is marked for close.
 T resource()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonBlockingAcquirableResource

public NonBlockingAcquirableResource(T resource)
Method Detail

resource

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

acquire

public boolean acquire()
Description copied from interface: AcquirableResource
Acquires the resource, returning true if it was acquired.

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

release

public void release()
Description copied from interface: AcquirableResource
Releases the resource, will close it if there are no more acquirers and it is marked for close.

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

markForClose

public void markForClose()
Description copied from interface: AcquirableResource
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>