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

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

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

Unsafe.compareAndSwapLong介绍

[英]Performs a compare-and-set operation on a long field within the given object.
[中]

代码示例

代码示例来源:origin: google/guava

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: google/guava

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: google/guava

final boolean cas(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
}

代码示例来源:origin: google/guava

final boolean cas(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
}

代码示例来源:origin: LMAX-Exchange/disruptor

/**
 * Perform a compare and set operation on the sequence.
 *
 * @param expectedValue The expected current value.
 * @param newValue The value to update to.
 * @return true if the operation succeeds, false otherwise.
 */
public boolean compareAndSet(final long expectedValue, final long newValue)
{
  return UNSAFE.compareAndSwapLong(this, VALUE_OFFSET, expectedValue, newValue);
}

代码示例来源:origin: prestodb/presto

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: prestodb/presto

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

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

@Override
public boolean compareAndSwapLong(long offset, long expect, long newVal) {
  return unsafe.compareAndSwapLong(base, off + offset, expect, newVal);
}

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

@Override
public boolean compareAndSwapLong(long offset, long expect, long newVal) {
  return unsafe.compareAndSwapLong(null, baseAdress + offset, expect, newVal);
}

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

/**
 * Atomically compare the current value of the given long field with the expected value, and if they are the
 * equal, set the field to the updated value and return true. Otherwise return false.
 * <p>
 * If this method returns true, then it has the memory visibility semantics of a volatile read followed by a
 * volatile write.
 */
public static boolean compareAndSwapLong(
    Object obj, long offset, long expected, long update )
{
  return unsafe.compareAndSwapLong( obj, offset, expected, update );
}

代码示例来源:origin: prestodb/presto

final boolean cas(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
}

代码示例来源:origin: prestodb/presto

final boolean cas(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
}

代码示例来源:origin: springside/springside4

/**
 * CASes the base field.
 */
final boolean casBase(long cmp, long val) {
  return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: vipshop/vjtools

/**
 * CASes the base field.
 */
final boolean casBase(long cmp, long val) {
  return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: alibaba/Sentinel

/**
 * CASes the base field.
 */
final boolean casBase(long cmp, long val) {
  return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: google/j2objc

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: google/j2objc

/** CASes the base field. */
final boolean casBase(long cmp, long val) {
 return UNSAFE.compareAndSwapLong(this, baseOffset, cmp, val);
}

代码示例来源:origin: ben-manes/caffeine

boolean casWriteCounter(long expect, long update) {
  return UnsafeAccess.UNSAFE.compareAndSwapLong(this, WRITE_OFFSET, expect, update);
 }
}

代码示例来源:origin: ben-manes/caffeine

boolean casWriteCounter(long expect, long update) {
  return UnsafeAccess.UNSAFE.compareAndSwapLong(this, WRITE_OFFSET, expect, update);
 }
}

代码示例来源:origin: ben-manes/caffeine

boolean casWriteCounter(long expect, long update) {
  return UnsafeAccess.UNSAFE.compareAndSwapLong(this, WRITE_OFFSET, expect, update);
 }
}

相关文章

Unsafe类方法