本文整理了Java中java.util.concurrent.atomic.AtomicReference.getAndAccumulate()
方法的一些代码示例,展示了AtomicReference.getAndAccumulate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AtomicReference.getAndAccumulate()
方法的具体详情如下:
包路径:java.util.concurrent.atomic.AtomicReference
类名称:AtomicReference
方法名:getAndAccumulate
暂无
代码示例来源:origin: apache/storm
idToResources.getAndAccumulate(resources, (orig, update) -> Utils.merge(orig, update));
idToWorkerResources.getAndAccumulate(workerResources, (orig, update) -> Utils.merge(orig, update));
代码示例来源:origin: one.util/streamex
private void drain(Consumer<? super T> action, T[] buf) {
T last = buf[idx-1];
T acc = accRef.getAndAccumulate(last, op);
if(acc != NONE) {
for(int i=0; i<idx; i++) {
action.accept(localOp.apply(buf[i], acc));
}
} else {
for(int i=0; i<idx; i++) {
action.accept(buf[i]);
}
}
}
代码示例来源:origin: stackoverflow.com
import java.math.BigInteger;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
public final class AtomicBigInteger {
private final AtomicReference<BigInteger> bigInteger;
public AtomicBigInteger(final BigInteger bigInteger) {
this.bigInteger = new AtomicReference<>(Objects.requireNonNull(bigInteger));
}
// Method references left out for demonstration purposes
public BigInteger incrementAndGet() {
return bigInteger.accumulateAndGet(BigInteger.ONE, (previous, x) -> previous.add(x));
}
public BigInteger getAndIncrement() {
return bigInteger.getAndAccumulate(BigInteger.ONE, (previous, x) -> previous.add(x));
}
public BigInteger get() {
return bigInteger.get();
}
}
代码示例来源:origin: com.github.msemys/esjc
private void processLiveQueue() {
do {
ResolvedEvent event;
while ((event = liveQueue.poll()) != null) {
// drop subscription artificial ResolvedEvent
if (event.equals(DROP_SUBSCRIPTION_EVENT)) {
DropData previousDropData = dropData.getAndAccumulate(UNKNOWN_DROP_DATA,
(current, update) -> (current == null) ? update : current);
if (previousDropData == null) {
previousDropData = UNKNOWN_DROP_DATA;
}
dropSubscription(previousDropData.reason, previousDropData.exception);
isProcessing.compareAndSet(true, false);
return;
}
try {
tryProcess(event);
} catch (Exception e) {
dropSubscription(SubscriptionDropReason.EventHandlerException, e);
return;
}
}
isProcessing.compareAndSet(true, false);
} while (!liveQueue.isEmpty() && isProcessing.compareAndSet(false, true));
}
代码示例来源:origin: msemys/esjc
private void processLiveQueue() {
do {
ResolvedEvent event;
while ((event = liveQueue.poll()) != null) {
// drop subscription artificial ResolvedEvent
if (event.equals(DROP_SUBSCRIPTION_EVENT)) {
DropData previousDropData = dropData.getAndAccumulate(UNKNOWN_DROP_DATA,
(current, update) -> (current == null) ? update : current);
if (previousDropData == null) {
previousDropData = UNKNOWN_DROP_DATA;
}
dropSubscription(previousDropData.reason, previousDropData.exception);
isProcessing.compareAndSet(true, false);
return;
}
try {
tryProcess(event);
} catch (Exception e) {
dropSubscription(SubscriptionDropReason.EventHandlerException, e);
return;
}
}
isProcessing.compareAndSet(true, false);
} while (!liveQueue.isEmpty() && isProcessing.compareAndSet(false, true));
}
代码示例来源:origin: com.github.msemys/esjc
DropData previousDropData = dropData.getAndAccumulate(UNKNOWN_DROP_DATA,
(current, update) -> (current == null) ? update : current);
代码示例来源:origin: msemys/esjc
DropData previousDropData = dropData.getAndAccumulate(UNKNOWN_DROP_DATA,
(current, update) -> (current == null) ? update : current);
内容来源于网络,如有侵权,请联系作者删除!