@SuppressWarnings("unchecked") protected final MpscLinkedQueueNode<E> getAndSetTailRef(MpscLinkedQueueNode<E> tailRef) { // LOCK XCHG in JDK8, a CAS loop in JDK 7/6 return (MpscLinkedQueueNode<E>) UPDATER.getAndSet(this, tailRef); } }
public Object takePartitionKeyLock() { // shortcut, much faster than getAndSet if (partitionKeyLock == null) { return null; } return PARTITION_KEY_LOCK_FIELD.getAndSet(this, null); }
/** * Atomically get and update the value of this array. * * @param instance the instance holding the field * @param value the new value */ public V[] getAndSet(T instance, V[] value) { return updater.getAndSet(instance, value); }
private void unparkWriteWaiters() { final Thread waiter = writeWaiterUpdater.getAndSet(this, null); if (waiter != null) { unpark(waiter); } }
@Override public void send( T event ) { AsyncEvent prev = STACK_UPDATER.getAndSet( this, event ); assert prev != null; event.next = prev; if ( prev == END_SENTINEL ) { LockSupport.unpark( backgroundThread ); } else if ( prev == SHUTDOWN_SENTINEL ) { AsyncEvent events = STACK_UPDATER.getAndSet( this, SHUTDOWN_SENTINEL ); process( events ); } }
public void cancelTimeouts() { TimeoutsHolder ref = TIMEOUTS_HOLDER_FIELD.getAndSet(this, null); if (ref != null) { ref.cancel(); } }
@Override public boolean cancelPendingReadRequest() { if (log.isDebugEnabled()) { log.debug("[{}] [{}] Cancel pending read request", ledger.getName(), name); } return WAITING_READ_OP_UPDATER.getAndSet(this, null) != null; }
void cancelInner() { FilterWhenInner a = asyncFilter; if (a != INNER_CANCELLED) { a = ASYNC_FILTER.getAndSet(this, INNER_CANCELLED); if (a != null && a != INNER_CANCELLED) { a.cancel(); } } }
@Override public void onNext(T t) { Object old = VALUE.getAndSet(this, t); if (old != null) { Operators.onDiscard(old, ctx); } }
@Override public void cancel() { Subscription sub = S.getAndSet(this, this); if (sub != null && sub != this) { sub.cancel(); } }
void startCreatingNewMetadataLedger() { // Change the state so that new mark-delete ops will be queued and not immediately submitted State oldState = STATE_UPDATER.getAndSet(this, State.SwitchingLedger); if (oldState == State.SwitchingLedger) { // Ignore double request return; } // Check if we can immediately switch to a new metadata ledger if (PENDING_MARK_DELETED_SUBMITTED_COUNT_UPDATER.get(this) == 0) { createNewMetadataLedger(); } }
void disposeResource(boolean isCancel) { Disposable d = disposable; if (d != OperatorDisposables.DISPOSED) { d = DISPOSABLE.getAndSet(this, OperatorDisposables.DISPOSED); if (d != null && d != OperatorDisposables.DISPOSED) { if (isCancel && d instanceof SinkDisposable) { ((SinkDisposable) d).cancel(); } d.dispose(); } } }
void cancelInner() { FilterWhenInner a = CURRENT.get(this); if (a != INNER_CANCELLED) { a = CURRENT.getAndSet(this, INNER_CANCELLED); if (a != null && a != INNER_CANCELLED) { a.cancel(); } } }
@Override public void asyncClose(final AsyncCallbacks.CloseCallback callback, final Object ctx) { State oldState = STATE_UPDATER.getAndSet(this, State.Closed); if (oldState == State.Closed) { log.info("[{}] [{}] State is already closed", ledger.getName(), name); callback.closeComplete(ctx); return; } persistPosition(-1, lastMarkDeleteEntry.newPosition, lastMarkDeleteEntry.properties, callback, ctx); }
public void failed(ManagedLedgerException e) { if (!checkAndCompleteTimeoutTask()) { return; } AddEntryCallback cb = callbackUpdater.getAndSet(this, null); data.release(); if (cb != null) { cb.addFailed(e, ctx); ml.mbean.recordAddEntryError(); } }
@Override public void cancel() { Disposable c = future; if (c != OperatorDisposables.DISPOSED) { c = FUTURE.getAndSet(this, OperatorDisposables.DISPOSED); if (c != null && !OperatorDisposables.isDisposed(c)) { c.dispose(); } value = null; } s.cancel(); }
@Override public void dispose() { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s != null && s != Operators.cancelledSubscription()) { s.cancel(); } } }
@Override public void dispose() { Subscription s = S.getAndSet(this, Operators.cancelledSubscription()); if (s != null && s != Operators.cancelledSubscription()) { s.cancel(); } } }
void cancelMain() { Subscription s = main; if (s != Operators.cancelledSubscription()) { s = MAIN.getAndSet(this, Operators.cancelledSubscription()); if (s != null && s != Operators.cancelledSubscription()) { s.cancel(); } } }
void cancelOther() { Subscription s = other; if (s != Operators.cancelledSubscription()) { s = OTHER.getAndSet(this, Operators.cancelledSubscription()); if (s != null && s != Operators.cancelledSubscription()) { s.cancel(); } } }