org.elasticsearch.common.util.concurrent.resource
Interface AcquirableResource<T extends Releasable>

All Known Implementing Classes:
BlockingAcquirableResource, NonBlockingAcquirableResource

public interface AcquirableResource<T extends Releasable>

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 resouce itself is releasable basically means that users of this class should take care... .


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()
           
 

Method Detail

resource

T resource()

acquire

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


release

void release()
Releases the resource, will close it if there are no more acquirers and it is marked for close.


markForClose

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


forceClose

void forceClose()
Forces the resource to be closed, regardless of the number of acquirers.