net.sf.jack4j
Class RingBufferVector

java.lang.Object
  extended by net.sf.jack4j.RingBufferVector

public class RingBufferVector
extends java.lang.Object

Allows access to readable or writable part of the RingBuffer, using direct NIO buffers.

Instances can be created using RingBuffer.createReadVector(java.nio.ByteOrder) and RingBuffer.createWriteVector(java.nio.ByteOrder) methods.

This class allows you to manipulate contents of the ringbuffer, without advancing read and write pointers (see RingBuffer.readAdvanceBytes(int) and RingBuffer.writeAdvanceBytes(int) methods if you want to advance that pointers afterwards).

While this type of access is quite efficient in native code, it doesn't perform well in Java, because the vector and the java.nio.Buffer objects must be created again whenever the ringbuffer pointers are advanced.

The class contains one or two ByteBuffer objects; first of them is never null (but may have zero capacity) and covers certain (readable or writable) part of the native ringbuffer. If the second ByteBuffer is not null, it covers additional part of the native ringbuffer.

Warning: whenever the read/write pointers of the ringbuffer are advanced, the previously created instance of this class is not valid anymore and must not be used.


Method Summary
 java.nio.ByteBuffer getFirstBuffer()
           
 java.nio.ByteBuffer getSecondBuffer()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFirstBuffer

public java.nio.ByteBuffer getFirstBuffer()
Returns:
the firstBuffer

getSecondBuffer

public java.nio.ByteBuffer getSecondBuffer()
Returns:
the secondBuffer


Copyright © 2008 Ondrej Par. All Rights Reserved.