deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

org.deegree.commons.utils.nio
Class DirectByteBufferPool

java.lang.Object
  extended by org.deegree.commons.utils.nio.DirectByteBufferPool

public class DirectByteBufferPool
extends Object

The DirectByteBufferPool pools a number of direct 'native' bytebuffers so they can be reused.

Version:
$Revision: $, $Date: $
Author:
Markus Schneider, last edited by: $Author: schneider $

Constructor Summary
DirectByteBufferPool(int capacityLimit, String name)
          Construct a direct byte buffer which may allocate buffers with given capacity
 
Method Summary
 PooledByteBuffer allocate_(int capacity)
           
 PooledByteBuffer allocate(int capacity)
           
 boolean canAllocate(int capacity)
           
 void deallocate(PooledByteBuffer buffer)
          Notifies the pool the given buffer is free for use.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectByteBufferPool

public DirectByteBufferPool(int capacityLimit,
                            String name)
Construct a direct byte buffer which may allocate buffers with given capacity

Parameters:
capacityLimit - total capacity of this pool.
name -
Method Detail

allocate

public PooledByteBuffer allocate(int capacity)
                          throws OutOfMemoryError
Parameters:
capacity -
Returns:
the requested byte buffer
Throws:
OutOfMemoryError - if no PooledByteBuffer with the given capacity is available and allocating it from the system would exceed the assigned resources

allocate_

public PooledByteBuffer allocate_(int capacity)
                           throws OutOfMemoryError
Parameters:
capacity -
Returns:
the requested byte buffer
Throws:
OutOfMemoryError - if no PooledByteBuffer with the given capacity is available and allocating it from the system would exceed the assigned resources

deallocate

public void deallocate(PooledByteBuffer buffer)
Notifies the pool the given buffer is free for use.

Parameters:
buffer - to be freed.

toString

public String toString()
Overrides:
toString in class Object

canAllocate

public boolean canAllocate(int capacity)
Parameters:
capacity -
Returns:
true if the pool has more free space.

deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org

]]>