sun.misc.Unsafe.storeFence()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中sun.misc.Unsafe.storeFence()方法的一些代码示例,展示了Unsafe.storeFence()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.storeFence()方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:storeFence

Unsafe.storeFence介绍

[英]Ensures lack of reordering of stores before the fence with loads or stores after the fence.
[中]确保围栏前的仓库没有重新排序,围栏后的仓库也没有重新排序。

代码示例

代码示例来源:origin: neo4j/neo4j

/**
 * Orders stores before the fence, with loads and stores after the fence.
 */
public static void storeFence()
{
  unsafe.storeFence();
}

代码示例来源:origin: real-logic/agrona

private void signalTailIntent(final AtomicBuffer buffer, final long newTail)
{
  buffer.putLongOrdered(tailIntentCountIndex, newTail);
  UnsafeAccess.UNSAFE.storeFence();
}

代码示例来源:origin: real-logic/agrona

/**
 * {@inheritDoc}
 */
public boolean write(final int msgTypeId, final DirectBuffer srcBuffer, final int srcIndex, final int length)
{
  checkTypeId(msgTypeId);
  checkMsgLength(length);
  boolean isSuccessful = false;
  final AtomicBuffer buffer = this.buffer;
  final int recordLength = length + HEADER_LENGTH;
  final int requiredCapacity = align(recordLength, ALIGNMENT);
  final int recordIndex = claimCapacity(buffer, requiredCapacity);
  if (INSUFFICIENT_CAPACITY != recordIndex)
  {
    buffer.putIntOrdered(lengthOffset(recordIndex), -recordLength);
    UnsafeAccess.UNSAFE.storeFence();
    buffer.putInt(typeOffset(recordIndex), msgTypeId);
    buffer.putBytes(encodedMsgOffset(recordIndex), srcBuffer, srcIndex, length);
    buffer.putIntOrdered(lengthOffset(recordIndex), recordLength);
    isSuccessful = true;
  }
  return isSuccessful;
}

代码示例来源:origin: real-logic/agrona

UnsafeAccess.UNSAFE.storeFence();

代码示例来源:origin: org.agrona/agrona

private void signalTailIntent(final AtomicBuffer buffer, final long newTail)
{
  buffer.putLongOrdered(tailIntentCountIndex, newTail);
  UnsafeAccess.UNSAFE.storeFence();
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
@ForceInline
public void storeFence() {
  UNSAFE.storeFence();
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
@ForceInline
public void storeFence() {
  UNSAFE.storeFence();
}

代码示例来源:origin: uk.co.real-logic/Agrona

private void signalTailIntent(final AtomicBuffer buffer, final long newTail)
{
  buffer.putLong(tailIntentCountIndex, newTail);
  UnsafeAccess.UNSAFE.storeFence();
}

代码示例来源:origin: org.agrona/Agrona

private void signalTailIntent(final AtomicBuffer buffer, final long newTail)
{
  buffer.putLong(tailIntentCountIndex, newTail);
  UnsafeAccess.UNSAFE.storeFence();
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void writeVolatileLong(@NotNull Object object, long offset, long i64) {
  if ((offset & 0x7) == 0) {
    super.writeVolatileLong(object, offset, i64);
  } else {
    writeLong(object, offset, i64);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
public void writeVolatileLong(@NotNull Object object, long offset, long i64) {
  if ((offset & 0x7) == 0) {
    super.writeVolatileLong(object, offset, i64);
  } else {
    writeLong(object, offset, i64);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
public void writeVolatileInt(long address, int i32) {
  if ((address & 0x3) == 0) {
    super.writeVolatileInt(address, i32);
  } else {
    writeInt(address, i32);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void writeVolatileShort(long address, short i16) {
  if ((address & 0x1) == 0) {
    super.writeVolatileShort(address, i16);
  } else {
    super.writeShort(address, i16);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void writeVolatileInt(long address, int i32) {
  if ((address & 0x3) == 0) {
    super.writeVolatileInt(address, i32);
  } else {
    writeInt(address, i32);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
public void writeVolatileShort(long address, short i16) {
  if ((address & 0x1) == 0) {
    super.writeVolatileShort(address, i16);
  } else {
    super.writeShort(address, i16);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: net.openhft/chronicle-core

@Override
public void writeVolatileLong(long address, long i64) {
  if ((address & 0x7) == 0) {
    super.writeVolatileLong(address, i64);
  } else {
    writeLong(address, i64);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: OpenHFT/Chronicle-Core

@Override
public void writeVolatileLong(long address, long i64) {
  if ((address & 0x7) == 0) {
    super.writeVolatileLong(address, i64);
  } else {
    writeLong(address, i64);
    UNSAFE.storeFence();
  }
}

代码示例来源:origin: bluestreak01/questdb

private void updateKeyCount(int key) {
  keyCount = key + 1;
  // also write key count to header of key memory
  long seq = keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE) + 1;
  keyMem.putLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE, seq);
  Unsafe.getUnsafe().storeFence();
  keyMem.putInt(BitmapIndexUtils.KEY_RESERVED_OFFSET_KEY_COUNT, keyCount);
  Unsafe.getUnsafe().storeFence();
  keyMem.putLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK, seq);
}

代码示例来源:origin: bluestreak01/questdb

private void updateValueMemSize() {
  long seq = keyMem.getLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE) + 1;
  keyMem.putLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE, seq);
  Unsafe.getUnsafe().storeFence();
  keyMem.putLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_VALUE_MEM_SIZE, valueMemSize);
  Unsafe.getUnsafe().storeFence();
  keyMem.putLong(BitmapIndexUtils.KEY_RESERVED_OFFSET_SEQUENCE_CHECK, seq);
}

代码示例来源:origin: bluestreak01/questdb

private void appendValue(long offset, long valueBlockOffset, long valueCount, int valueCellIndex, long value) {
  // first set value
  valueMem.putLong(valueBlockOffset + valueCellIndex * 8L, value);
  Unsafe.getUnsafe().storeFence();
  // update count and last value block offset for the key
  // in atomic fashion
  keyMem.putLong(offset, valueCount + 1);
  // write count check
  keyMem.putLong(offset + KEY_ENTRY_OFFSET_COUNT_CHECK, valueCount + 1);
}

相关文章

Unsafe类方法