Interface Allocator

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ArrayAllocator, BufferAllocator, FileAllocator, FilterAllocator

public interface Allocator extends Closeable
The Allocator interface is used to describe a resource that can allocate a buffer. This is used so that memory allocation can be implemented as a strategy allowing many different sources of memory. Typically memory will be allocated as an array of bytes but can be a mapped region of shared memory or a file.
Author:
Niall Gallagher
  • Method Summary

    Modifier and Type
    Method
    Description
    This method is used to allocate a default buffer.
    allocate(int size)
    This method is used to allocate a default buffer.
    void
    This method is used to close the allocator so that resources that are occupied by the allocator can be freed.
  • Method Details

    • allocate

      Buffer allocate() throws IOException
      This method is used to allocate a default buffer. Typically this will allocate a buffer of predetermined size, allowing it to grow to an upper limit to accommodate extra data. If the buffer can not be allocated for some reason this throws an exception.
      Returns:
      this returns an allocated buffer with a default size
      Throws:
      IOException
    • allocate

      Buffer allocate(int size) throws IOException
      This method is used to allocate a default buffer. This is used to allocate a buffer of the specified size, allowing it to grow to an upper limit to accommodate extra data. If the buffer can not be allocated for some reason this throws an exception.
      Parameters:
      size - this is the initial capacity the buffer should have
      Returns:
      this returns an allocated buffer with a specified size
      Throws:
      IOException
    • close

      void close() throws IOException
      This method is used to close the allocator so that resources that are occupied by the allocator can be freed. This will allow the allocator to be created and closed repeatedly in a single process without holding on to resources such as mapped file buffers or threads.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException