org.deegree.commons.utils.nio
Class DirectByteBufferPool
java.lang.Object
org.deegree.commons.utils.nio.DirectByteBufferPool
public class DirectByteBufferPool
- extends java.lang.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,
java.lang.String name)
Construct a direct byte buffer which may allocate buffers with given capacity |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DirectByteBufferPool
public DirectByteBufferPool(int capacityLimit,
java.lang.String name)
- Construct a direct byte buffer which may allocate buffers with given capacity
- Parameters:
capacityLimit
- total capacity of this pool.name
-
allocate
public PooledByteBuffer allocate(int capacity)
throws java.lang.OutOfMemoryError
- Parameters:
capacity
-
- Returns:
- the requested byte buffer
- Throws:
java.lang.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 java.lang.OutOfMemoryError
- Parameters:
capacity
-
- Returns:
- the requested byte buffer
- Throws:
java.lang.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 java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
canAllocate
public boolean canAllocate(int capacity)
- Parameters:
capacity
-
- Returns:
- true if the pool has more free space.
Copyright © 2011. All Rights Reserved.