Java Code Examples for org.agrona.concurrent.UnsafeBuffer#boundsCheck()

The following examples show how to use org.agrona.concurrent.UnsafeBuffer#boundsCheck() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TermAppender.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a view over a term buffer and state buffer for appending frames.
 *
 * @param termBuffer     for where messages are stored.
 * @param metaDataBuffer for where the state of writers is stored manage concurrency.
 * @param partitionIndex for this will be the active appender.
 */
public TermAppender(final UnsafeBuffer termBuffer, final UnsafeBuffer metaDataBuffer, final int partitionIndex)
{
    final int tailCounterOffset = TERM_TAIL_COUNTERS_OFFSET + (partitionIndex * SIZE_OF_LONG);
    metaDataBuffer.boundsCheck(tailCounterOffset, SIZE_OF_LONG);

    this.termBuffer = termBuffer;
    tailAddressOffset = metaDataBuffer.addressOffset() + tailCounterOffset;
}
 
Example 2
Source File: ExclusiveTermAppender.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a view over a term buffer and state buffer for appending frames.
 *
 * @param termBuffer     for where messages are stored.
 * @param metaDataBuffer for where the state of writers is stored manage concurrency.
 * @param partitionIndex for this will be the active appender.
 */
public ExclusiveTermAppender(
    final UnsafeBuffer termBuffer, final UnsafeBuffer metaDataBuffer, final int partitionIndex)
{
    final int tailCounterOffset = TERM_TAIL_COUNTERS_OFFSET + (partitionIndex * SIZE_OF_LONG);
    metaDataBuffer.boundsCheck(tailCounterOffset, SIZE_OF_LONG);

    this.termBuffer = termBuffer;
    tailAddressOffset = metaDataBuffer.addressOffset() + tailCounterOffset;
}
 
Example 3
Source File: UnsafeBufferPosition.java    From agrona with Apache License 2.0 5 votes vote down vote up
/**
 * Map a position over a buffer and this indicator owns the counter for reclamation.
 *
 * @param buffer          containing the counter.
 * @param counterId       identifier of the counter.
 * @param countersManager to be used for freeing the counter when this is closed.
 */
public UnsafeBufferPosition(final UnsafeBuffer buffer, final int counterId, final CountersManager countersManager)
{
    this.counterId = counterId;
    this.countersManager = countersManager;
    this.byteArray = buffer.byteArray();
    this.byteBuffer = buffer.byteBuffer();

    final int counterOffset = CountersManager.counterOffset(counterId);
    buffer.boundsCheck(counterOffset, SIZE_OF_LONG);
    this.addressOffset = buffer.addressOffset() + counterOffset;
}