Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io
Class BufferManagerAdapter

java.lang.Object
  extended by com.tangosol.io.BufferManagerAdapter

All Implemented Interfaces:
MultiBufferWriteBuffer.WriteBufferPool

public class BufferManagerAdapter
extends java.lang.Object
implements MultiBufferWriteBuffer.WriteBufferPool

The BufferManagerAdapter is a WriteBufferPool implementation that is backed by a BufferManager.

This implementation also tracks all ByteBuffer objects allocated by the underlying BufferManager.


Field Summary
protected  java.nio.ByteBuffer m_buffer
          The current (last allocated) buffer.

 

Constructor Summary
BufferManagerAdapter(BufferManager mgr)
          Construct BufferManagerAdapter based on the specified BufferManager.

 

Method Summary
 WriteBuffer allocate(int cbPreviousTotal)
          Allocate a WriteBuffer for use by the MultiBufferWriteBuffer.
 int getMaximumCapacity()
          Determine the largest amount of aggregate WriteBuffer capacity that this factory can provide.
 void release(WriteBuffer buffer)
          This method should not be called.
 BufferSequence toBufferSequence()
          Create a BufferSequence based on the list of ByteBuffers allocated by this adapter.

 

Field Detail

m_buffer

protected java.nio.ByteBuffer m_buffer
The current (last allocated) buffer.

Constructor Detail

BufferManagerAdapter

public BufferManagerAdapter(BufferManager mgr)
Construct BufferManagerAdapter based on the specified BufferManager.
Parameters:
mgr - the underlying BufferManager

Method Detail

getMaximumCapacity

public int getMaximumCapacity()
Determine the largest amount of aggregate WriteBuffer capacity that this factory can provide.
Specified by:
getMaximumCapacity in interface MultiBufferWriteBuffer.WriteBufferPool
Returns:
the number of bytes that can be stored in the WriteBuffer objects that may be returned from this factory

allocate

public WriteBuffer allocate(int cbPreviousTotal)
Allocate a WriteBuffer for use by the MultiBufferWriteBuffer. The MultiBufferWriteBuffer calls this factory method when it exhausts the storage capacity of previously allocated WriteBuffer objects.

Note that the returned WriteBuffer is expected to be empty, and its capacity is expected to be identical to its maximum capacity, i.e. it is not expected to resize itself, since the purpose of the MultiBufferWriteBuffer is to act as a dynamically-sized WriteBuffer.

Specified by:
allocate in interface MultiBufferWriteBuffer.WriteBufferPool
Parameters:
cbPreviousTotal - the total number of bytes of capacity of the WriteBuffer objects that the MultiBufferWriteBuffer has thus far consumed
Returns:
an empty WriteBuffer suitable for writing to

release

public void release(WriteBuffer buffer)
This method should not be called.
Specified by:
release in interface MultiBufferWriteBuffer.WriteBufferPool
Parameters:
buffer - the WriteBuffer that is no longer being used

toBufferSequence

public BufferSequence toBufferSequence()
Create a BufferSequence based on the list of ByteBuffers allocated by this adapter. Subsequent modifications to the buffers and buffer positions are not allowed.
Returns:
the BufferSequence representing allocated buffers

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.