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

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

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

Unsafe.putOrderedObject介绍

[英]Lazy set an object field.
[中]设置一个对象字段。

代码示例

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

@Override
public void lazySet(U obj, M newValue) {
  unsafe.putOrderedObject(obj, offset, newValue);
}

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

/**
 * An ordered store(store + StoreStore barrier) of an element to a given offset
 *
 * @param buffer this.buffer
 * @param offset computed via {@link UnsafeRefArrayAccess#calcElementOffset}
 * @param e an orderly kitty
 */
public static <E> void soElement(E[] buffer, long offset, E e) {
 UNSAFE.putOrderedObject(buffer, offset, e);
}

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

void lazySetTail(Node<E> next) {
 UnsafeAccess.UNSAFE.putOrderedObject(this, TAIL_OFFSET, next);
}

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

final void soBlocked(Thread thread)
  {
    UNSAFE.putOrderedObject(this, BLOCKED_OFFSET, thread);
  }
}

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

/**
 * An ordered store(store + StoreStore barrier) of an element to a given offset
 *
 * @param buffer this.buffer
 * @param offset computed via {@link UnsafeRefArrayAccess#calcElementOffset}
 * @param e      an orderly kitty
 */
public static <E> void soElement(E[] buffer, long offset, E e)
{
  UNSAFE.putOrderedObject(buffer, offset, e);
}

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

/**
 * Sets next field with volatile write semantics.  (See above
 * about use of putOrderedObject.)
 */
final void setNext(HashEntry<K,V> n) {
  UNSAFE.putOrderedObject(this, nextOffset, n);
}

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

/**
 * Sets the ith element of given table, with volatile write
 * semantics. (See above about use of putOrderedObject.)
 */
static final <K,V> void setEntryAt(HashEntry<K,V>[] tab, int i,
                  HashEntry<K,V> e) {
  UNSAFE.putOrderedObject(tab, ((long)i << TSHIFT) + TBASE, e);
}

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

/**
 * Eventually sets to the given value.
 *
 * @param newValue the new value
 * @since 1.6
 */
public final void lazySet(V newValue) {
  unsafe.putOrderedObject(this, valueOffset, newValue);
}

代码示例来源:origin: apache/ignite

void lazySetPrev(Node<E> val) {
  UNSAFE.putOrderedObject(this, prevOffset, val);
}

代码示例来源:origin: apache/ignite

void lazySetNext(Node<E> val) {
  UNSAFE.putOrderedObject(this, nextOffset, val);
}

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

void lazySetPrev(Node<E> val) {
  UNSAFE.putOrderedObject(this, prevOffset, val);
}

代码示例来源:origin: h2oai/h2o-2

void lazySetPrev(Node<E> val) {
  UNSAFE.putOrderedObject(this, prevOffset, val);
}

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

public void soNext(LinkedQueueNode<E> n)
{
  UNSAFE.putOrderedObject(this, NEXT_OFFSET, n);
}

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

void lazySetNext(@Nullable Node<E> newNext) {
 UnsafeAccess.UNSAFE.putOrderedObject(this, NEXT_OFFSET, newNext);
}

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

void setRelaxedObject(Object value) {
 UnsafeAccess.UNSAFE.putOrderedObject(this, MoreRelaxedFields.OVALUE_OFFSET, value);
}

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

/**
 * Eventually sets the element at position {@code i} to the given value.
 *
 * @param i the index
 * @param newValue the new value
 * @since 1.6
 */
public final void lazySet(int i, E newValue) {
  unsafe.putOrderedObject(array, checkedByteOffset(i), newValue);
}

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

public void lazySet(T obj, V newValue) {
  if (obj == null || obj.getClass() != tclass || cclass != null ||
    (newValue != null && vclass != null &&
     vclass != newValue.getClass()))
    updateCheck(obj, newValue);
  unsafe.putOrderedObject(obj, offset, newValue);
}

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

public ManyToOneConcurrentLinkedQueue()
{
  headOrdered(empty);
  UNSAFE.putOrderedObject(this, TAIL_OFFSET, empty);
}

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

public E poll() {
  if (head >= batchHead) {
    if (!backtrackPoll()) {
      return null;
    }
  }
  final long offset = offset(head);
  @SuppressWarnings("unchecked")
  final E e = (E) UNSAFE.getObject(buffer, offset);
  UNSAFE.putOrderedObject(buffer, offset, null);
  head++;
  return e;
}

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

@Override
public int offer(E e) {
 long head = readCounter;
 long tail = relaxedWriteCounter();
 long size = (tail - head);
 if (size >= SPACED_SIZE) {
  return FULL;
 }
 if (casWriteCounter(tail, tail + OFFSET)) {
  long offset = ((tail & SPACED_MASK) << SHIFT) + BASE;
  UnsafeAccess.UNSAFE.putOrderedObject(buffer, offset, e);
  return SUCCESS;
 }
 return FAILED;
}

相关文章

Unsafe类方法