本文整理汇总了Java中java.util.concurrent.atomic.AtomicLong.decrementAndGet方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicLong.decrementAndGet方法的具体用法?Java AtomicLong.decrementAndGet怎么用?Java AtomicLong.decrementAndGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.AtomicLong
的用法示例。
在下文中一共展示了AtomicLong.decrementAndGet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tick
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
void tick() {
AtomicLong localCounter = this.counter;
if (localCounter.getAndIncrement() == 0) {
int emitted = 0;
do {
if (this.requested.get() > 0) {
Object o = this.buffer.poll();
if (o != null) {
if (this.buffer.isCompleted(o)) {
this.child.onCompleted();
} else {
this.buffer.accept(o, this.child);
emitted++;
this.requested.decrementAndGet();
}
}
}
} while (localCounter.decrementAndGet() > 0);
if (emitted > 0) {
for (MultiSourceRequestableSubscriber<T, R> s : this.subscribers) {
s.requestUpTo((long) emitted);
}
}
}
}
示例2: emitItem
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
private void emitItem(GroupState<K, T> groupState, Object item) {
Queue<Object> q = groupState.buffer;
AtomicLong keyRequested = groupState.requested;
REQUESTED.decrementAndGet(this);
if (keyRequested == null || keyRequested.get() <= 0 || !(q == null || q.isEmpty())) {
q.add(item);
BUFFERED_COUNT.incrementAndGet(this);
if (groupState.count.getAndIncrement() == 0) {
pollQueue(groupState);
}
} else {
nl.accept(groupState.getObserver(), item);
if (keyRequested.get() != Long.MAX_VALUE) {
keyRequested.decrementAndGet();
}
}
requestMoreIfNecessary();
}
示例3: checkExecution
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
private void checkExecution(final RPromise<Long> result, final AtomicReference<Throwable> failed,
final AtomicLong count, final AtomicLong executed) {
if (executed.decrementAndGet() == 0) {
if (failed.get() != null) {
if (count.get() > 0) {
RedisException ex = new RedisException("" + count.get() + " keys has been deleted. But one or more nodes has an error", failed.get());
result.tryFailure(ex);
} else {
result.tryFailure(failed.get());
}
} else {
result.trySuccess(count.get());
}
}
}
示例4: call
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public Subscriber<? super T> call(final Subscriber<? super T> child) {
final AtomicLong requested = new AtomicLong();
child.setProducer(new Producer() {
public void request(long n) {
BackpressureUtils.getAndAddRequest(requested, n);
}
});
return new Subscriber<T>(child) {
public void onStart() {
request(Long.MAX_VALUE);
}
public void onCompleted() {
child.onCompleted();
}
public void onError(Throwable e) {
child.onError(e);
}
public void onNext(T t) {
if (requested.get() > 0) {
child.onNext(t);
requested.decrementAndGet();
} else if (OperatorOnBackpressureDrop.this.onDrop != null) {
OperatorOnBackpressureDrop.this.onDrop.call(t);
}
}
};
}
示例5: pollQueue
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
void pollQueue() {
int emitted = 0;
AtomicLong localRequested = this.requested;
AtomicLong localCounter = this.counter;
do {
localCounter.set(1);
long produced = 0;
long r = localRequested.get();
while (!this.child.isUnsubscribed()) {
if (this.finished) {
Throwable error = this.error;
if (error != null) {
this.queue.clear();
this.child.onError(error);
return;
} else if (this.queue.isEmpty()) {
this.child.onCompleted();
return;
}
}
if (r > 0) {
Object o = this.queue.poll();
if (o != null) {
this.child.onNext(this.on.getValue(o));
r--;
emitted++;
produced++;
}
}
if (produced > 0 && localRequested.get() != Long.MAX_VALUE) {
localRequested.addAndGet(-produced);
}
}
return;
} while (localCounter.decrementAndGet() > 0);
if (emitted > 0) {
request((long) emitted);
}
}
示例6: tick
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
void tick() {
Object[] observers = this.observers;
if (observers != null && getAndIncrement() == 0) {
int length = observers.length;
Observer<? super R> child = this.child;
AtomicLong requested = this.requested;
while (true) {
RxRingBuffer buffer;
Object[] vs = new Object[length];
boolean allHaveValues = true;
for (int i = 0; i < length; i++) {
buffer = ((InnerSubscriber) observers[i]).items;
Object n = buffer.peek();
if (n == null) {
allHaveValues = false;
} else if (buffer.isCompleted(n)) {
child.onCompleted();
this.childSubscription.unsubscribe();
return;
} else {
vs[i] = buffer.getValue(n);
}
}
if (requested.get() > 0 && allHaveValues) {
try {
child.onNext(this.zipFunction.call(vs));
requested.decrementAndGet();
this.emitted++;
for (Object obj : observers) {
buffer = ((InnerSubscriber) obj).items;
buffer.poll();
if (buffer.isCompleted(buffer.peek())) {
child.onCompleted();
this.childSubscription.unsubscribe();
return;
}
}
if (this.emitted > THRESHOLD) {
for (Object obj2 : observers) {
((InnerSubscriber) obj2).requestMore((long) this.emitted);
}
this.emitted = 0;
}
} catch (Throwable e) {
Exceptions.throwOrReport(e, child, vs);
return;
}
} else if (decrementAndGet() <= 0) {
return;
}
}
}
}
示例7: checkCreated
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@VisibleForTesting
Boolean checkCreated(Context context, Key key, String id, AtomicLong retry, Duration interval) {
Key.KeyBuilder builder = Key.build(key);
while (true) {
Key current = builder.build();
if (context.getState(current) == StateType.TERMINATE) {
log.trace("Reconciling create terminated : {}", id);
return FALSE;
}
Order order = context.findOrder(current, id);
if (order != null) {
log.trace("Reconcile create succeeded : {}", id);
return TRUE;
}
if (retry.decrementAndGet() < 0) {
break;
}
try {
Thread.sleep(interval.toMillis());
builder.timestamp(current.getTimestamp().plus(interval));
} catch (InterruptedException e) {
log.trace("Reconciling create interrupted : {}", id);
return FALSE;
}
}
log.trace("Reconcile create failed : {}", id);
return FALSE;
}
示例8: checkCancelled
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@VisibleForTesting
Boolean checkCancelled(Context context, Key key, String id, AtomicLong retry, Duration interval) {
Key.KeyBuilder builder = Key.build(key);
while (true) {
Key current = builder.build();
if (context.getState(current) == StateType.TERMINATE) {
log.trace("Reconciling cancel terminated : {}", id);
return FALSE;
}
Order order = context.findOrder(current, id);
if (order == null || !TRUE.equals(order.getActive())) {
log.trace("Reconcile cancel succeeded : {}", id);
return TRUE;
}
if (retry.decrementAndGet() < 0) {
break;
}
try {
Thread.sleep(interval.toMillis());
builder.timestamp(current.getTimestamp().plus(interval));
} catch (InterruptedException e) {
log.trace("Reconciling cancel interrupted : {}", id);
return FALSE;
}
}
log.trace("Reconcile cancel failed : {}", id);
return FALSE;
}