org.deegree.commons.utils.nio
Class DirectByteBufferPool
java.lang.Object
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 |
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
-
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.
Copyright © 2011. All Rights Reserved.