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

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

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

Unsafe.getAndSetLong介绍

[英]Atomically exchanges the given value with the current value of a field or array element within the given object o at the given offset.
[中]在给定[$1$]位置,将给定值与给定对象o中的字段或数组元素的当前值进行原子交换。

代码示例

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

/**
 * Atomically exchanges provided <code>newValue</code> with the current value of field or array element, with
 * provided <code>offset</code>.
 */
public static long getAndSetLong( Object object, long offset, long newValue )
{
  return unsafe.getAndSetLong( object, offset, newValue );
}

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

@Override
  protected long getAndReset(long[] cells, long offset) {
    return UNSAFE.getAndSetLong(cells, offset, 0L);
  }
}

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

/**
 * Get the current value of a counter and atomically set it to a new value.
 *
 * @param value to be set.
 * @return the previous value of the counter
 */
public long getAndSet(final long value)
{
  return UnsafeAccess.UNSAFE.getAndSetLong(byteArray, addressOffset, value);
}

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

public long getAndSetLong(final long index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(null, addressOffset + index, value);
}

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

public long getAndSetLong(final int index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(byteArray, addressOffset + index, value);
}

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

/**
 * Get the current value of a counter and atomically set it to a new value.
 *
 * @param value to be set.
 * @return the previous value of the counter
 */
public long getAndSet(final long value)
{
  return UnsafeAccess.UNSAFE.getAndSetLong(byteArray, addressOffset, value);
}

代码示例来源:origin: io.kamon/kamon-core

/**
 * CASes the base field.
 */
final long getAndSetBase(long val) {
  return U.getAndSetLong(this, BASE, val);
}

代码示例来源:origin: dragome/dragome-sdk

/**
 * Atomically sets to the given value and returns the old value.
 *
 * @param newValue the new value
 * @return the previous value
 */
public final long getAndSet(long newValue) {
  return unsafe.getAndSetLong(this, valueOffset, newValue);
}

代码示例来源:origin: org.neo4j/neo4j-unsafe

/**
 * Atomically exchanges provided <code>newValue</code> with the current value of field or array element, with
 * provided <code>offset</code>.
 */
public static long getAndSetLong( Object object, long offset, long newValue )
{
  return unsafe.getAndSetLong( object, offset, newValue );
}

代码示例来源:origin: io.kamon/kamon-core_2.12

/**
 * CASes the base field.
 */
final long getAndSetBase(long val) {
  return U.getAndSetLong(this, BASE, val);
}

代码示例来源:origin: org.sincron/sincron-atomic

public long getAndSet(long update) {
    return UnsafeAccess.UNSAFE.getAndSetLong(this, OFFSET, update);
  }
}

代码示例来源:origin: org.sincron/sincron-atomic

public long getAndSet(long update) {
    return UnsafeAccess.UNSAFE.getAndSetLong(this, OFFSET, update);
  }
}

代码示例来源:origin: io.snappydata/gemfire-core

/**
 * {@inheritDoc}
 */
@Override
public final long getAndSet(T obj, long newValue) {
 return unsafe.getAndSetLong(obj, offset, newValue);
}

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

public long getAndSetLong(final long index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(null, addressOffset + index, value);
}

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

public long getAndSetLong(final long index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(null, addressOffset + index, value);
}

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

public long getAndSetLong(final int index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(byteArray, addressOffset + index, value);
}

代码示例来源:origin: org.caffinitas.ohc/ohc-core

static long getAndPutLong(long address, long offset, long value)
{
  validate(address, offset, 8L);
  return unsafe.getAndSetLong(null, address + offset, value);
}

代码示例来源:origin: snazy/ohc

static long getAndPutLong(long address, long offset, long value)
{
  validate(address, offset, 8L);
  return unsafe.getAndSetLong(null, address + offset, value);
}

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

public long getAndSetLong(final int index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(byteArray, addressOffset + index, value);
}

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

public long getAndSetLong(final int index, final long value)
{
  if (SHOULD_BOUNDS_CHECK)
  {
    boundsCheck0(index, SIZE_OF_LONG);
  }
  return UNSAFE.getAndSetLong(byteArray, addressOffset + index, value);
}

相关文章

Unsafe类方法