MpscChunkedAtomicArrayQueueColdProducerFields(int initialCapacity, int maxCapacity) { super(initialCapacity); RangeUtil.checkGreaterThanOrEqual(maxCapacity, 4, "maxCapacity"); RangeUtil.checkLessThan(roundToPowerOfTwo(initialCapacity), roundToPowerOfTwo(maxCapacity), "initialCapacity"); maxQueueCapacity = ((long) Pow2.roundToPowerOfTwo(maxCapacity)) << 1; } }
@SuppressWarnings("unchecked") protected BQueueColdFields(int capacity) { if (Pow2.isPowerOfTwo(capacity)) { this.capacity = capacity; } else { this.capacity = Pow2.roundToPowerOfTwo(capacity); } mask = this.capacity - 1; buffer = (E[]) new Object[this.capacity + BUFFER_PAD * 2]; } }
@SuppressWarnings("unchecked") public ConcurrentCircularArray(int capacity) { int actualCapacity = Pow2.roundToPowerOfTwo(capacity); mask = actualCapacity - 1; // pad data on either end with some empty slots. buffer = (E[]) new Object[(actualCapacity << SPARSE_SHIFT) + BUFFER_PAD * 2]; }
public SpscOffHeapIntQueue(final int capacity) { this(allocateAlignedByteBuffer( getRequiredBufferSize(capacity), PortableJvmInfo.CACHE_LINE_SIZE), Pow2.roundToPowerOfTwo(capacity),(byte)(PRODUCER | CONSUMER)); }
/** * Write a reference to the given position * @param offset index into the reference array * @param reference */ protected void writeReference(long offset, Object reference) { assert referenceMessageSize != 0 : "References are not in use"; // Is there a way to compute the element offset once and just // arithmetic? UnsafeRefArrayAccess.spElement(references, UnsafeRefArrayAccess.calcElementOffset(offset), reference); }
/** * Read a reference at the given position * @param offset index into the reference array * @return */ protected Object readReference(long offset) { assert referenceMessageSize != 0 : "References are not in use"; // Is there a way to compute the element offset once and just // arithmetic? return UnsafeRefArrayAccess.lpElement(references, UnsafeRefArrayAccess.calcElementOffset(offset)); }
private Object spinWaitForElement(E[] buffer, long offset) { Object e; do { e = lvElement(buffer, offset); } while (e == null); return e; }
@InternalAPI public interface IndexedQueue { long lvConsumerIndex(); long lvProducerIndex(); } }
private Object readTagValue(String tagName, Object obj, boolean last) { Object value = readBuiltinTag(tagName, obj, last); if (value != null) return value; return readField(tagName, obj); }
@SuppressWarnings("unchecked") public MpmcConcurrentQueueSMBuffer(int capacity) { if (Pow2.isPowerOfTwo(capacity)) { this.capacity = capacity; } else { this.capacity = Pow2.roundToPowerOfTwo(capacity); } mask = this.capacity - 1; // pad data on either end with some empty slots. buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2]; }
public OffHeapFixedMessageSizeRingBuffer(final int capacity, final int primitiveMessageSize, int referenceMessageSize) { this(allocateAlignedByteBuffer(getRequiredBufferSize(capacity, primitiveMessageSize), CACHE_LINE_SIZE), Pow2.roundToPowerOfTwo(capacity), true, true, true, primitiveMessageSize, createReferenceArray(capacity, referenceMessageSize), referenceMessageSize); }
MpscChunkedArrayQueueColdProducerFields(int initialCapacity, int maxCapacity) { super(initialCapacity); RangeUtil.checkGreaterThanOrEqual(maxCapacity, 4, "maxCapacity"); RangeUtil.checkLessThan(roundToPowerOfTwo(initialCapacity), roundToPowerOfTwo(maxCapacity), "initialCapacity"); maxQueueCapacity = ((long) Pow2.roundToPowerOfTwo(maxCapacity)) << 1; } }
@SuppressWarnings("unchecked") public IdentityOpenHashSet(int capacity) { int actualCapacity = Pow2.roundToPowerOfTwo(capacity); // pad data on either end with some empty slots? buffer = (E[]) new Object[actualCapacity]; resizeThreshold = (int) (0.75 * buffer.length); }
private E spinForElement(final E[] buffer, long offset) { E e; do { e = lvElement(buffer, offset); } while (e == null); return e; }
@SuppressWarnings("unchecked") InlinedRingBufferColdFields(int capacity) { if (Pow2.isPowerOfTwo(capacity)) { this.capacity = capacity; } else { this.capacity = Pow2.roundToPowerOfTwo(capacity); } mask = this.capacity - 1; buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2]; } }
public MpscOffHeapFixedSizeRingBuffer(final int capacity, final int messageSize, int referenceMessageSize) { this(allocateAlignedByteBuffer(getRequiredBufferSize(capacity, messageSize), PortableJvmInfo.CACHE_LINE_SIZE), Pow2.roundToPowerOfTwo(capacity), true, true, true, messageSize, createReferenceArray(capacity, referenceMessageSize), referenceMessageSize); }
@SuppressWarnings("unchecked") public SingleWriterHashSet(int capacity) { int actualCapacity = Pow2.roundToPowerOfTwo(capacity); // pad data on either end with some empty slots? buffer = (E[]) new Object[actualCapacity]; resizeThreshold = (int) (0.75 * buffer.length); }
@SuppressWarnings("unchecked") FloatingCaqColdFields(int capacity) { if (Pow2.isPowerOfTwo(capacity)) { this.capacity = capacity; } else { this.capacity = Pow2.roundToPowerOfTwo(capacity); } mask = this.capacity - 1; buffer = (E[]) new Object[(this.capacity << SPARSE_SHIFT) + BUFFER_PAD * 2]; } }
public SpscOffHeapFixedSizeRingBuffer(final int capacity, final int messageSize, final int referenceMessageSize) { this(allocateAlignedByteBuffer(getRequiredBufferSize(capacity, messageSize), CACHE_LINE_SIZE), Pow2.roundToPowerOfTwo(capacity), true, true, true, messageSize, createReferenceArray(capacity, referenceMessageSize), referenceMessageSize); }
@SuppressWarnings("unchecked") public OpenHashSet(int capacity) { int actualCapacity = Pow2.roundToPowerOfTwo(capacity); // pad data on either end with some empty slots? buffer = (E[]) new Object[actualCapacity]; resizeThreshold = (int) (0.75 * buffer.length); }