本文整理了Java中sun.misc.Unsafe.loadFence()
方法的一些代码示例,展示了Unsafe.loadFence()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.loadFence()
方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:loadFence
[英]Ensures lack of reordering of loads before the fence with loads or stores after the fence.
[中]确保围栏前的货物与围栏后的货物或仓库没有重新排序。
代码示例来源:origin: neo4j/neo4j
/**
* Orders loads before the fence, with loads and stores after the fence.
*/
public static void loadFence()
{
unsafe.loadFence();
}
代码示例来源:origin: real-logic/agrona
/**
* Validate that the current received record is still valid and has not been overwritten.
* <p>
* If the receiver is not consuming messages fast enough to keep up with the transmitter then loss
* can be experienced resulting in messages being overwritten thus making them no longer valid.
*
* @return true if still valid otherwise false.
*/
public boolean validate()
{
UNSAFE.loadFence();
return validate(cursor);
}
代码示例来源:origin: real-logic/aeron
final int receiverWindowLength = nextSmReceiverWindowLength;
UNSAFE.loadFence();
代码示例来源:origin: real-logic/aeron
final int length = lossLength;
UNSAFE.loadFence();
代码示例来源:origin: Netflix/hollow
private boolean readWasUnsafe(HollowMapTypeDataElements data) {
HollowUnsafeHandle.getUnsafe().loadFence();
return data != currentDataVolatile;
}
代码示例来源:origin: Netflix/hollow
private boolean readWasUnsafe(HollowSetTypeDataElements data) {
HollowUnsafeHandle.getUnsafe().loadFence();
return data != currentDataVolatile;
}
代码示例来源:origin: Netflix/hollow
private boolean readWasUnsafe(HollowListTypeDataElements data) {
HollowUnsafeHandle.getUnsafe().loadFence();
return data != currentDataVolatile;
}
代码示例来源:origin: Netflix/hollow
private boolean readWasUnsafe(HollowObjectTypeDataElements data) {
// Use a load (acquire) fence to constrain the compiler reordering prior plain loads so
// that they cannot "float down" below the volatile load of currentDataVolatile.
// This ensures data is checked against currentData *after* optimistic calculations
// have been performed on data.
//
// Note: the Java Memory Model allows for the reordering of plain loads and stores
// before a volatile load (those plain loads and stores can "float down" below the
// volatile load), but forbids the reordering of plain loads after a volatile load
// (those plain loads are not allowed to "float above" the volatile load).
// Similar reordering also applies to plain loads and stores and volatile stores.
// In effect the ordering of volatile loads and stores is retained and plain loads
// and stores can be shuffled around and grouped together, which increases
// optimization opportunities.
// This is why locks can be coarsened; plain loads and stores may enter the lock region
// from above (float down the acquire) or below (float above the release) but existing
// loads and stores may not exit (a "lock roach motel" and why there is almost universal
// misunderstanding of, and many misguided attempts to optimize, the infamous double
// checked locking idiom).
//
// Note: the fence provides stronger ordering guarantees than a corresponding non-plain
// load or store since the former affects all prior or subsequent loads and stores,
// whereas the latter is scoped to the particular load or store.
//
// For more details see http://gee.cs.oswego.edu/dl/html/j9mm.html
HollowUnsafeHandle.getUnsafe().loadFence();
return data != currentDataVolatile;
}
代码示例来源:origin: org.neo4j/neo4j-unsafe
/**
* Orders loads before the fence, with loads and stores after the fence.
*/
public static void loadFence()
{
unsafe.loadFence();
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
@ForceInline
public void loadFence() {
UNSAFE.loadFence();
}
代码示例来源:origin: org.cojen/tupl
public boolean isZero() {
// Volatile read prevents reordering the relaxed slot gets combined
// with the loadFence() below.
long sum = relaxed;
for (int i = 0; i < SLOTS && sum == 0; i++) {
sum += get(i);
}
UNSAFE.loadFence();
return sum == 0;
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public long readVolatileLong(@NotNull Object object, long offset) {
if ((offset & 0x7) == 0) return super.readVolatileLong(object, offset);
UNSAFE.loadFence();
return readLong(object, offset);
}
代码示例来源:origin: OpenHFT/Chronicle-Core
@Override
public long readVolatileLong(@NotNull Object object, long offset) {
if ((offset & 0x7) == 0) return super.readVolatileLong(object, offset);
UNSAFE.loadFence();
return readLong(object, offset);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public float readVolatileFloat(long address) {
if ((address & 0x3) == 0)
return super.readVolatileFloat(address);
UNSAFE.loadFence();
return readFloat(address);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public double readVolatileDouble(long address) {
if ((address & 0x7) == 0)
return super.readVolatileDouble(address);
UNSAFE.loadFence();
return readDouble(address);
}
代码示例来源:origin: OpenHFT/Chronicle-Core
@Override
public int readVolatileInt(long address) {
if ((address & 0x3) == 0)
return super.readVolatileInt(address);
UNSAFE.loadFence();
return super.readInt(address);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public long readVolatileLong(long address) {
if ((address & 0x7) == 0)
return super.readVolatileLong(address);
UNSAFE.loadFence();
return readLong(address);
}
代码示例来源:origin: OpenHFT/Chronicle-Core
@Override
public short readVolatileShort(long address) {
if ((address & 0x1) == 0)
return super.readVolatileShort(address);
UNSAFE.loadFence();
return super.readShort(address);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public short readVolatileShort(long address) {
if ((address & 0x1) == 0)
return super.readVolatileShort(address);
UNSAFE.loadFence();
return super.readShort(address);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
public int readVolatileInt(long address) {
if ((address & 0x3) == 0)
return super.readVolatileInt(address);
UNSAFE.loadFence();
return super.readInt(address);
}
内容来源于网络,如有侵权,请联系作者删除!