本文整理了Java中sun.misc.Unsafe.getAndAddInt()
方法的一些代码示例,展示了Unsafe.getAndAddInt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.getAndAddInt()
方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:getAndAddInt
[英]Atomically adds the given value to the current value of a field or array element within the given object o
at the given offset
.
[中]以原子方式将给定值添加到给定对象o
中给定offset
处的字段或数组元素的当前值。
代码示例来源:origin: neo4j/neo4j
/**
* Atomically add the given delta to the int field, and return its previous value.
* <p>
* This has the memory visibility semantics of a volatile read followed by a volatile write.
*/
public static int getAndAddInt( Object obj, long offset, int delta )
{
return unsafe.getAndAddInt( obj, offset, delta );
}
代码示例来源:origin: apache/hbase
@Override
protected int incrementRefCountAndGet() {
return unsafe.getAndAddInt(this, refCountOffset, 1) + 1;
}
代码示例来源:origin: apache/hbase
@Override
protected int decrementRefCountAndGet() {
return unsafe.getAndAddInt(this, refCountOffset, -1) - 1;
}
代码示例来源:origin: real-logic/agrona
public int getAndAddInt(final long index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(null, addressOffset + index, delta);
}
代码示例来源:origin: real-logic/agrona
public int getAndAddInt(final int index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(byteArray, addressOffset + index, delta);
}
代码示例来源:origin: ehcache/ehcache3
} finally {
Thread w;
if (U.getAndAddInt(this, LOCKSTATE, -READER) ==
(READER|WAITER) && (w = waiter) != null)
LockSupport.unpark(w);
代码示例来源:origin: snazy/ohc
static boolean decrement(long address, long offset)
{
validate(address, offset, 4L);
long v = unsafe.getAndAddInt(null, address + offset, -1);
return v == 1;
}
代码示例来源:origin: org.caffinitas.ohc/ohc-core
static void increment(long address, long offset)
{
validate(address, offset, 4L);
unsafe.getAndAddInt(null, address + offset, 1);
}
代码示例来源:origin: zeebe-io/zeebe
@Override
public void signal() {
UNSAFE.getAndAddInt(this, TRIGGER_COUNT_OFFSET, 1);
task.tryWakeup();
}
代码示例来源:origin: org.agrona/Agrona
public int getAndAddInt(final int index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(byteArray, addressOffset + index, delta);
}
代码示例来源:origin: snazy/ohc
static void increment(long address, long offset)
{
validate(address, offset, 4L);
unsafe.getAndAddInt(null, address + offset, 1);
}
代码示例来源:origin: org.agrona/agrona
public int getAndAddInt(final int index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(byteArray, addressOffset + index, delta);
}
代码示例来源:origin: net.openhft/chronicle-core
@Override
@ForceInline
public int addInt(@NotNull Object object, long offset, int increment) {
// assert (offset & 0x3) == 0;
if (object == null)
throw new NullPointerException();
return UNSAFE.getAndAddInt(object, offset, increment) + increment;
}
代码示例来源:origin: OpenHFT/Chronicle-Core
@Override
@ForceInline
public int addInt(long address, int increment) {
// assert (address & 0x3) == 0;
return UNSAFE.getAndAddInt(null, address, increment) + increment;
}
代码示例来源:origin: org.agrona/agrona
public int getAndAddInt(final long index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(null, addressOffset + index, delta);
}
代码示例来源:origin: org.agrona/Agrona
public int getAndAddInt(final long index, final int delta)
{
if (SHOULD_BOUNDS_CHECK)
{
boundsCheck0(index, SIZE_OF_INT);
}
return UNSAFE.getAndAddInt(null, addressOffset + index, delta);
}
代码示例来源:origin: io.zeebe/zb-util
@Override
public void signal() {
UNSAFE.getAndAddInt(this, TRIGGER_COUNT_OFFSET, 1);
task.tryWakeup();
}
代码示例来源:origin: hank-whu/turbo-rpc
private int insertIndex() {
int index = unsafe().getAndAddInt(this, SIZE_OFFSET, 1);
ensureCapacity(index + 1);
return index;
}
代码示例来源:origin: hank-whu/turbo-rpc
/**
* 增加并获取该位置的值
*
* @param index
* @param delta
* @return
*/
public int addAndGet(int index, int delta) {
Objects.checkIndex(index, count);
return unsafe().getAndAddInt(array, offset(index), delta) + delta;
}
代码示例来源:origin: hank-whu/turbo-rpc
/**
* 递增并获取该位置的值
*
* @param index
* @return
*/
public int incrementAndGet(int index) {
Objects.checkIndex(index, count);
return unsafe().getAndAddInt(array, offset(index), 1) + 1;
}
内容来源于网络,如有侵权,请联系作者删除!