2015/07/26 - Apache DirectMemory has been retired.

For more information, please explore the Attic.

public class

FixedSizeUnsafeAllocator

extends Object
implements Allocator
java.lang.Object
   ↳ org.apache.directmemory.memory.allocator.FixedSizeUnsafeAllocator

Summary

Public Constructors
FixedSizeUnsafeAllocator(int number, int size)
Public Methods
MemoryBuffer allocate(int size)
Allocates and returns a MemoryBuffer with capacity() set to the given size.
void clear()
Clear all allocated MemoryBuffer, resulting in a empty and ready to deserve Allocator
void close()
void free(MemoryBuffer memoryBuffer)
Returns the given MemoryBuffer making it available for a future usage.
int getCapacity()
int getNumber()
Protected Methods
MemoryBuffer findFreeBuffer(int capacity)
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Closeable
From interface org.apache.directmemory.memory.allocator.Allocator

Public Constructors

public FixedSizeUnsafeAllocator (int number, int size)

Public Methods

public MemoryBuffer allocate (int size)

Allocates and returns a MemoryBuffer with capacity() set to the given size. When the allocation fails, it returns either null or throws an BufferOverflowException, depending on the implementation.

Parameters
size : the size in byte to allocate
Returns
  • a MemoryBuffer of the given size, or either return null or throw an BufferOverflowException when the allocation fails.

public void clear ()

Clear all allocated MemoryBuffer, resulting in a empty and ready to deserve Allocator

public void close ()

Throws
IOException

public void free (MemoryBuffer memoryBuffer)

Returns the given MemoryBuffer making it available for a future usage. Returning twice a MemoryBuffer won't throw an exception.

Parameters
memoryBuffer : the MemoryBuffer to return

public int getCapacity ()

public int getNumber ()

Protected Methods

protected MemoryBuffer findFreeBuffer (int capacity)