TrueZIP Kernel 7.0-rc1

de.schlichtherle.truezip.util
Interface Pool<R,E extends Exception>

All Known Subinterfaces:
IOPool<E>
All Known Implementing Classes:
ByteArrayIOPool, IOCache.InputBufferPool, IOCache.OutputBufferPool, IOCache.WriteBackOutputBufferPool, IOCache.WriteThroughOutputBufferPool

public interface Pool<R,E extends Exception>

An interface for pooling strategies.

Implementations must be thread-safe. However, this does not necessarily apply to the implementation of its managed resources.

Author:
Christian Schlichtherle

Nested Class Summary
static interface Pool.Releasable<E extends Exception>
          This interface is designed to be used with Pools which enable their resources to release itself.
 
Method Summary
 R allocate()
          Allocates a resource from this pool.
 void release(R resource)
          Releases a previously allocated resource to this pool.
 

Method Detail

allocate

@NonNull
R allocate()
           throws E extends Exception
Allocates a resource from this pool.

Returns:
A resource.
Throws:
Exception - if allocating the resource failed for any reason.

release

void release(@NonNull
             R resource)
             throws E extends Exception
Releases a previously allocated resource to this pool. Implementations may throw an IllegalArgumentException or an IllegalStateException upon the conditions explained below.

Parameters:
resource - a resource.
Throws:
IllegalArgumentException - if the given resource has not been allocated by this pool and the implementation doesn't tolerate this.
IllegalStateException - if the given resource has already been released to this pool and the implementation doesn't tolerate this.
Exception - if releasing the resource failed for any other reason.

TrueZIP Kernel 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.