Skip to content

Commit

Permalink
[Java] Remove MemoryAccess.
Browse files Browse the repository at this point in the history
  • Loading branch information
vyazelenko committed Nov 11, 2024
1 parent 9f60c42 commit 894ed3d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 105 deletions.
52 changes: 0 additions & 52 deletions agrona/src/main/java/org/agrona/concurrent/MemoryAccess.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.AtomicBuffer;
import org.agrona.concurrent.MemoryAccess;

import java.lang.invoke.VarHandle;
import java.util.concurrent.atomic.AtomicLong;

import static org.agrona.BitUtil.align;
Expand Down Expand Up @@ -191,7 +191,7 @@ public boolean receiveNext()
*/
public boolean validate()
{
MemoryAccess.acquireFence();
VarHandle.acquireFence();

return validate(cursor, buffer, capacity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import org.agrona.BitUtil;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.AtomicBuffer;
import org.agrona.concurrent.MemoryAccess;

import java.lang.invoke.VarHandle;

import static org.agrona.concurrent.broadcast.BroadcastBufferDescriptor.*;
import static org.agrona.concurrent.broadcast.RecordDescriptor.*;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void transmit(final int msgTypeId, final DirectBuffer srcBuffer, final in
private void signalTailIntent(final AtomicBuffer buffer, final long newTail)
{
buffer.putLongOrdered(tailIntentCountIndex, newTail);
MemoryAccess.releaseFence();
VarHandle.releaseFence();
}

private static void insertPaddingRecord(final AtomicBuffer buffer, final int recordOffset, final int length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import org.agrona.DirectBuffer;
import org.agrona.concurrent.AtomicBuffer;
import org.agrona.concurrent.ControlledMessageHandler;
import org.agrona.concurrent.MemoryAccess;
import org.agrona.concurrent.MessageHandler;

import java.lang.invoke.VarHandle;

import static java.lang.Math.max;
import static org.agrona.BitUtil.align;
import static org.agrona.concurrent.ControlledMessageHandler.Action.*;
Expand Down Expand Up @@ -97,7 +98,7 @@ public boolean write(final int msgTypeId, final DirectBuffer srcBuffer, final in
}

buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
MemoryAccess.releaseFence();
VarHandle.releaseFence();

buffer.putBytes(encodedMsgOffset(recordIndex), srcBuffer, offset, length);
buffer.putInt(typeOffset(recordIndex), msgTypeId);
Expand All @@ -124,7 +125,7 @@ public int tryClaim(final int msgTypeId, final int length)
}

buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
MemoryAccess.releaseFence();
VarHandle.releaseFence();
buffer.putInt(typeOffset(recordIndex), msgTypeId);

return encodedMsgOffset(recordIndex);
Expand Down Expand Up @@ -536,7 +537,7 @@ private int claimCapacity(final AtomicBuffer buffer, final int recordLength)
if (0 != padding)
{
buffer.putIntOrdered(lengthOffset(tailIndex), -padding);
MemoryAccess.releaseFence();
VarHandle.releaseFence();

buffer.putInt(typeOffset(tailIndex), PADDING_MSG_TYPE_ID);
buffer.putIntOrdered(lengthOffset(tailIndex), padding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
import org.agrona.DirectBuffer;
import org.agrona.concurrent.AtomicBuffer;
import org.agrona.concurrent.ControlledMessageHandler;
import org.agrona.concurrent.MemoryAccess;
import org.agrona.concurrent.MessageHandler;

import java.lang.invoke.VarHandle;

import static java.lang.Math.max;
import static org.agrona.BitUtil.align;
import static org.agrona.concurrent.ControlledMessageHandler.Action.*;
Expand Down Expand Up @@ -100,7 +101,7 @@ public boolean write(final int msgTypeId, final DirectBuffer srcBuffer, final in
}

buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
MemoryAccess.releaseFence();
VarHandle.releaseFence();

buffer.putBytes(encodedMsgOffset(recordIndex), srcBuffer, offset, length);
buffer.putInt(typeOffset(recordIndex), msgTypeId);
Expand All @@ -127,7 +128,7 @@ public int tryClaim(final int msgTypeId, final int length)
}

buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
MemoryAccess.releaseFence();
VarHandle.releaseFence();
buffer.putInt(typeOffset(recordIndex), msgTypeId);

return encodedMsgOffset(recordIndex);
Expand Down Expand Up @@ -472,7 +473,7 @@ else if (requiredCapacity > toBufferEndLength)
{
buffer.putLong(0, 0L);
buffer.putIntOrdered(lengthOffset(recordIndex), -padding);
MemoryAccess.releaseFence();
VarHandle.releaseFence();

buffer.putInt(typeOffset(recordIndex), PADDING_MSG_TYPE_ID);
buffer.putIntOrdered(lengthOffset(recordIndex), padding);
Expand Down
41 changes: 0 additions & 41 deletions agrona/src/test/java/org/agrona/concurrent/MemoryAccessTest.java

This file was deleted.

0 comments on commit 894ed3d

Please sign in to comment.