本文整理汇总了Java中java.util.concurrent.atomic.AtomicLong.get方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicLong.get方法的具体用法?Java AtomicLong.get怎么用?Java AtomicLong.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.AtomicLong
的用法示例。
在下文中一共展示了AtomicLong.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: getPutMessageSizeTotal
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long getPutMessageSizeTotal() {
long rs = 0;
for (AtomicLong data : putMessageTopicSizeTotal.values()) {
rs += data.get();
}
return rs;
}
示例3: getPutMessageTimesTotal
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long getPutMessageTimesTotal() {
long rs = 0;
for (AtomicLong data : putMessageTopicTimesTotal.values()) {
rs += data.get();
}
return rs;
}
示例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: updateNumberOfWaits
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
private static void updateNumberOfWaits(AtomicLong start, AtomicLong maxTime) {
Long now = System.currentTimeMillis();
Long startValue = start.get();
if (startValue != 0 && now - startValue > 1000) {
maxTime.incrementAndGet();
}
start.set(now);
}
示例6: clearBit
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
protected void clearBit(AtomicLong atomic, long lMask) {
long lWord;
do {
lWord = atomic.get();
} while (!atomic.compareAndSet(lWord, lWord & ~lMask));
if ((atomic.get() & lMask) != 0L) {
throw new InternalError();
}
}
示例7: deleteAll
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
@Override
public long deleteAll() {
final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
final AtomicLong count = new AtomicLong();
metadata.forEach(r -> {
final IMap<String, Ticket> instance = getTicketMapInstanceByMetadata(r);
if (instance != null) {
count.addAndGet(instance.size());
instance.evictAll();
instance.clear();
}
});
return count.get();
}
示例8: setBit
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
protected void setBit(AtomicLong atomic, long lMask) {
long lWord;
do {
lWord = atomic.get();
} while (!atomic.compareAndSet(lWord, lWord | lMask));
if ((atomic.get() & lMask) == 0L) {
throw new InternalError();
}
}
示例9: postCompleteRequest
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
* Accumulates requests (not validated) and handles the completed mode draining of the queue based on the requests.
*
* <p>
* Post-completion backpressure handles the case when a source produces values based on
* requests when it is active but more values are available even after its completion.
* In this case, the onComplete() can't just emit the contents of the queue but has to
* coordinate with the requested amounts. This requires two distinct modes: active and
* completed. In active mode, requests flow through and the queue is not accessed but
* in completed mode, requests no-longer reach the upstream but help in draining the queue.
*
* @param <T> the value type emitted
* @param n the request amount, positive (not validated)
* @param actual the target Subscriber to send events to
* @param queue the queue to drain if in the post-complete state
* @param state holds the request amount and the post-completed flag
* @param isCancelled a supplier that returns true if the drain has been cancelled
* @return true if the state indicates a completion state.
*/
public static <T> boolean postCompleteRequest(long n,
Subscriber<? super T> actual,
Queue<T> queue,
AtomicLong state,
BooleanSupplier isCancelled) {
for (; ; ) {
long r = state.get();
// extract the current request amount
long r0 = r & REQUESTED_MASK;
// preserve COMPLETED_MASK and calculate new requested amount
long u = (r & COMPLETED_MASK) | BackpressureHelper.addCap(r0, n);
if (state.compareAndSet(r, u)) {
// (complete, 0) -> (complete, n) transition then replay
if (r == COMPLETED_MASK) {
postCompleteDrain(n | COMPLETED_MASK, actual, queue, state, isCancelled);
return true;
}
// (active, r) -> (active, r + n) transition then continue with requesting from upstream
return false;
}
}
}
示例10: setNewLargestValue
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
*
* @param value
* @param newValue
*/
private static boolean setNewLargestValue(AtomicLong value, long newValue) {
boolean done = false;
while (!done) {
long oldValue = value.get();
if (oldValue < newValue) {
return value.compareAndSet(oldValue, newValue);
} else {
done = true;
}
}
return false;
}
示例11: compareAndSetMax
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public static void compareAndSetMax(final AtomicLong target, final long value) {
long prev = target.get();
while (value > prev) {
boolean updated = target.compareAndSet(prev, value);
if (updated)
break;
prev = target.get();
}
}
示例12: recalculatePullFromWhichNode
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public long recalculatePullFromWhichNode(final MessageQueue mq) {
if (this.isConnectBrokerByUser()) {
return this.defaultBrokerId;
}
AtomicLong suggest = this.pullFromWhichNodeTable.get(mq);
if (suggest != null) {
return suggest.get();
}
return MixAll.MASTER_ID;
}
示例13: compareAndIncreaseOnly
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public static boolean compareAndIncreaseOnly(final AtomicLong target, final long value) {
long prev = target.get();
while (value > prev) {
boolean updated = target.compareAndSet(prev, value);
if (updated)
return true;
prev = target.get();
}
return false;
}
示例14: ProducerStat
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
public ProducerStat(String topic, String group, AtomicLong successNums, AtomicLong errorNums,
AtomicLong latestSuccessNums, AtomicLong latestErrorNums) {
super();
this.topic = topic;
this.group = group;
this.successNums = successNums.get();
this.errorNums = errorNums.get();
this.latestSuccessNums = latestSuccessNums.get();
this.latestErrorNums = latestErrorNums.get();
this.updateTime = System.currentTimeMillis();
}
示例15: toString
import java.util.concurrent.atomic.AtomicLong; //导入方法依赖的package包/类
/**
* Returns a string identifying this pool, as well as its state,
* including indications of run state, parallelism level, and
* worker and task counts.
*
* @return a string identifying this pool, as well as its state
*/
public String toString() {
// Use a single pass through workQueues to collect counts
long qt = 0L, qs = 0L; int rc = 0;
AtomicLong sc = stealCounter;
long st = (sc == null) ? 0L : sc.get();
long c = ctl;
WorkQueue[] ws; WorkQueue w;
if ((ws = workQueues) != null) {
for (int i = 0; i < ws.length; ++i) {
if ((w = ws[i]) != null) {
int size = w.queueSize();
if ((i & 1) == 0)
qs += size;
else {
qt += size;
st += w.nsteals;
if (w.isApparentlyUnblocked())
++rc;
}
}
}
}
int pc = (config & SMASK);
int tc = pc + (short)(c >>> TC_SHIFT);
int ac = pc + (int)(c >> AC_SHIFT);
if (ac < 0) // ignore transient negative
ac = 0;
int rs = runState;
String level = ((rs & TERMINATED) != 0 ? "Terminated" :
(rs & STOP) != 0 ? "Terminating" :
(rs & SHUTDOWN) != 0 ? "Shutting down" :
"Running");
return super.toString() +
"[" + level +
", parallelism = " + pc +
", size = " + tc +
", active = " + ac +
", running = " + rc +
", steals = " + st +
", tasks = " + qt +
", submissions = " + qs +
"]";
}