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

The following examples show how to use org.agrona.concurrent.UnsafeBuffer#putLongOrdered() . 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: IpcPublication.java    From aeron with Apache License 2.0 6 votes vote down vote up
private void cleanBufferTo(final long position)
{
    final long cleanPosition = this.cleanPosition;
    if (position > cleanPosition)
    {
        final UnsafeBuffer dirtyTerm = termBuffers[indexByPosition(cleanPosition, positionBitsToShift)];
        final int bytesForCleaning = (int)(position - cleanPosition);
        final int bufferCapacity = termBufferLength;
        final int termOffset = (int)cleanPosition & (bufferCapacity - 1);
        final int length = Math.min(bytesForCleaning, bufferCapacity - termOffset);

        dirtyTerm.setMemory(termOffset + SIZE_OF_LONG, length - SIZE_OF_LONG, (byte)0);
        dirtyTerm.putLongOrdered(termOffset, 0);
        this.cleanPosition = cleanPosition + length;
    }
}
 
Example 2
Source File: TermRebuilder.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Insert a packet of frames into the log at the appropriate termOffset as indicated by the term termOffset header.
 * <p>
 * If the packet has already been inserted then this is a noop.
 *
 * @param termBuffer into which the packet should be inserted.
 * @param termOffset in the term at which the packet should be inserted.
 * @param packet     containing a sequence of frames.
 * @param length     of the packet of frames in bytes.
 */
public static void insert(
    final UnsafeBuffer termBuffer, final int termOffset, final UnsafeBuffer packet, final int length)
{
    if (0 == termBuffer.getInt(termOffset))
    {
        termBuffer.putBytes(termOffset + HEADER_LENGTH, packet, HEADER_LENGTH, length - HEADER_LENGTH);

        termBuffer.putLong(termOffset + 24, packet.getLong(24));
        termBuffer.putLong(termOffset + 16, packet.getLong(16));
        termBuffer.putLong(termOffset + 8, packet.getLong(8));

        termBuffer.putLongOrdered(termOffset, packet.getLong(0));
    }
}
 
Example 3
Source File: PublicationImage.java    From aeron with Apache License 2.0 5 votes vote down vote up
private void cleanBufferTo(final long position)
{
    final long cleanPosition = this.cleanPosition;
    if (position > cleanPosition)
    {
        final int bytesForCleaning = (int)(position - cleanPosition);
        final UnsafeBuffer dirtyTerm = termBuffers[indexByPosition(cleanPosition, positionBitsToShift)];
        final int termOffset = (int)cleanPosition & termLengthMask;
        final int length = Math.min(bytesForCleaning, dirtyTerm.capacity() - termOffset);

        dirtyTerm.setMemory(termOffset, length - SIZE_OF_LONG, (byte)0);
        dirtyTerm.putLongOrdered(termOffset + (length - SIZE_OF_LONG), 0);
        this.cleanPosition = cleanPosition + length;
    }
}
 
Example 4
Source File: NetworkPublication.java    From aeron with Apache License 2.0 5 votes vote down vote up
private void cleanBufferTo(final long position)
{
    final long cleanPosition = this.cleanPosition;
    if (position > cleanPosition)
    {
        final UnsafeBuffer dirtyTerm = termBuffers[indexByPosition(cleanPosition, positionBitsToShift)];
        final int bytesForCleaning = (int)(position - cleanPosition);
        final int termOffset = (int)cleanPosition & termLengthMask;
        final int length = Math.min(bytesForCleaning, termBufferLength - termOffset);

        dirtyTerm.setMemory(termOffset + SIZE_OF_LONG, length - SIZE_OF_LONG, (byte)0);
        dirtyTerm.putLongOrdered(termOffset, 0);
        this.cleanPosition = cleanPosition + length;
    }
}
 
Example 5
Source File: LogBufferDescriptor.java    From aeron with Apache License 2.0 2 votes vote down vote up
/**
 * Set the value of the end of stream position.
 *
 * @param metadataBuffer containing the meta data.
 * @param position       value of the end of stream position
 */
public static void endOfStreamPosition(final UnsafeBuffer metadataBuffer, final long position)
{
    metadataBuffer.putLongOrdered(LOG_END_OF_STREAM_POSITION_OFFSET, position);
}