예제 #1
0
abstract class SpmcArrayQueueConsumerField<E> extends SpmcArrayQueueL2Pad<E> {
  protected static final long C_INDEX_OFFSET =
      UnsafeAccess.addressOf(SpmcArrayQueueConsumerField.class, "consumerIndex");
  private volatile long consumerIndex;

  public SpmcArrayQueueConsumerField(int capacity) {
    super(capacity);
  }

  protected final long lvConsumerIndex() {
    return consumerIndex;
  }

  protected final boolean casHead(long expect, long newValue) {
    return UNSAFE.compareAndSwapLong(this, C_INDEX_OFFSET, expect, newValue);
  }
}
예제 #2
0
abstract class SpmcArrayQueueProducerField<E> extends SpmcArrayQueueL1Pad<E> {
  protected static final long P_INDEX_OFFSET =
      UnsafeAccess.addressOf(SpmcArrayQueueProducerField.class, "producerIndex");
  private volatile long producerIndex;

  protected final long lvProducerIndex() {
    return producerIndex;
  }

  protected final void soTail(long v) {
    UNSAFE.putOrderedLong(this, P_INDEX_OFFSET, v);
  }

  public SpmcArrayQueueProducerField(int capacity) {
    super(capacity);
  }
}