void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
void add(DefaultHandle<?> handle) { handle.lastRecycledId = id; Link tail = this.tail; int writeIndex; if ((writeIndex = tail.get()) == LINK_CAPACITY) { if (!head.reserveSpace(LINK_CAPACITY)) { // Drop it. return; } // We allocate a Link so reserve the space this.tail = tail = tail.next = new Link(); writeIndex = tail.get(); } tail.elements[writeIndex] = handle; handle.stack = null; // we lazy set to ensure that setting stack to null appears before we unnull it in the owning thread; // this also means we guarantee visibility of an element in the queue if we see the index updated tail.lazySet(writeIndex + 1); }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
boolean reserveSpace(int space) { return reserveSpace(availableSharedCapacity, space); }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }