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

For more information, please explore the Attic.

public class

LazyUnsafeAllocator

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

Summary

Public Constructors
LazyUnsafeAllocator(int number, long capacity)
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()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.io.Closeable
From interface org.apache.directmemory.memory.allocator.Allocator

Public Constructors

public LazyUnsafeAllocator (int number, long capacity)

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 ()