Top Description Inners Fields Constructors Methods
com.amazon.ion.impl.bin

pack-priv final Class PooledBlockAllocatorProvider

extends BlockAllocatorProvider
Class Inheritance
Imports
java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .ConcurrentMap, java.util.concurrent.atomic.AtomicInteger

A singleton implementation of BlockAllocatorProvider offering a thread-safe free block list for each block size.

This implementation is thread-safe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PooledBlockAllocatorProvider.PooledBlockAllocator

A BlockAllocator of for a particular size that has a single thread-safe free list.

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<Integer, BlockAllocator>
private static final PooledBlockAllocatorProvider

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PooledBlockAllocatorProvider
public BlockAllocator
vendAllocator(final int blockSize)

Implements abstract com.amazon.ion.impl.bin.BlockAllocatorProvider.vendAllocator.

Returns a BlockAllocator that vends blocks of the given size.

Field Detail

allocatorsback to summary
private final ConcurrentMap<Integer, BlockAllocator> allocators
INSTANCEback to summary
private static final PooledBlockAllocatorProvider INSTANCE

Constructor Detail

PooledBlockAllocatorProviderback to summary
private PooledBlockAllocatorProvider()

Method Detail

getInstanceback to summary
public static PooledBlockAllocatorProvider getInstance()
vendAllocatorback to summary
public BlockAllocator vendAllocator(final int blockSize)

Implements abstract com.amazon.ion.impl.bin.BlockAllocatorProvider.vendAllocator.

Doc from com.amazon.ion.impl.bin.BlockAllocatorProvider.vendAllocator.

Returns a BlockAllocator that vends blocks of the given size. This method can be used across threads, but the returned BlockAllocator instances are not thread-safe and must have their BlockAllocator#close() method called to allow its underlying resources to be released or reused properly.

Annotations
@Override
com.amazon.ion.impl.bin back to summary

private final Class PooledBlockAllocatorProvider.PooledBlockAllocator

extends BlockAllocator
Class Inheritance

A BlockAllocator of for a particular size that has a single thread-safe free list.

This implementation is thread-safe.

Field Summary

Modifier and TypeField and Description
private final int
private final int
pack-priv static final int
private final ConcurrentLinkedQueue<Block>
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
public
PooledBlockAllocator(final int blockSize)

Method Summary

Modifier and TypeMethod and Description
public Block
allocateBlock()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.allocateBlock.

Allocates a Block instance to the caller.

public void
close()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.close.

Implements java.io.Closeable.close.

Releases the allocator back to the BlockAllocatorProvider from whence it came.

public int
getBlockSize()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.getBlockSize.

Returns the fixed block size of the allocator.

Field Detail

blockLimitback to summary
private final int blockLimit
blockSizeback to summary
private final int blockSize
FREE_CAPACITYback to summary
pack-priv static final int FREE_CAPACITY
freeBlocksback to summary
private final ConcurrentLinkedQueue<Block> freeBlocks
sizeback to summary
private final AtomicInteger size

Constructor Detail

PooledBlockAllocatorback to summary
public PooledBlockAllocator(final int blockSize)

Method Detail

allocateBlockback to summary
public Block allocateBlock()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.allocateBlock.

Doc from com.amazon.ion.impl.bin.BlockAllocator.allocateBlock.

Allocates a Block instance to the caller. The caller owns the block until Block#close() is called--once Block#close() is called, an implementation may re-allocate it to another caller.

Annotations
@Override
closeback to summary
public void close()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.close.

Implements java.io.Closeable.close.

Doc from com.amazon.ion.impl.bin.BlockAllocator.close.

Releases the allocator back to the BlockAllocatorProvider from whence it came. This is used to allow underlying resources to be reclaimed and/or released properly.

Annotations
@Override
getBlockSizeback to summary
public int getBlockSize()

Implements abstract com.amazon.ion.impl.bin.BlockAllocator.getBlockSize.

Doc from com.amazon.ion.impl.bin.BlockAllocator.getBlockSize.

Returns the fixed block size of the allocator.

Annotations
@Override