本文整理了Java中java.util.concurrent.atomic.AtomicInteger.getAndDecrement()
方法的一些代码示例,展示了AtomicInteger.getAndDecrement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AtomicInteger.getAndDecrement()
方法的具体详情如下:
包路径:java.util.concurrent.atomic.AtomicInteger
类名称:AtomicInteger
方法名:getAndDecrement
[英]Atomically decrements by one the current value.
[中]原子地将当前值递减1。
代码示例来源:origin: apache/incubator-druid
@Override
public void onSuccess(InputStream result)
{
openConnections.getAndDecrement();
}
代码示例来源:origin: apache/hbase
/** Report that checksum was ok, so we may ponder going back to HBase checksum. */
public void checksumOk() {
if (this.useHBaseChecksumConfigured && !this.useHBaseChecksum
&& (this.hbaseChecksumOffCount.getAndDecrement() < 0)) {
// The stream we need is already open (because we were using HBase checksum in the past).
assert this.streamNoFsChecksum != null;
this.useHBaseChecksum = true;
}
}
代码示例来源:origin: apache/hbase
private boolean remove(SimpleServerRpcConnection connection) {
boolean removed = connections.remove(connection);
if (removed) {
count.getAndDecrement();
}
return removed;
}
代码示例来源:origin: btraceio/btrace
static int getAndDecrement(AtomicInteger ai) {
if (ai instanceof BTraceAtomicInteger) {
return ai.getAndDecrement();
} else {
throw new IllegalArgumentException();
}
}
代码示例来源:origin: apache/incubator-druid
public void elementRemoved(E e)
{
currentSize.addAndGet(-1 * getBytesSize(e));
elementCount.getAndDecrement();
}
代码示例来源:origin: org.testng/testng
/**
* Retries the test if count is not 0.
* @param result The result of the test.
*/
@Override
public boolean retry(ITestResult result) {
if (count.getAndDecrement() > 0) {
return retryMethod(result);
}
return false;
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected synchronized void release() {
if (wifiManager != null) {
shadowOf(wifiManager).activeLockCount.getAndDecrement();
}
if (refCounted) {
if (--refCount < 0) throw new RuntimeException("WifiLock under-locked");
} else {
locked = false;
}
}
代码示例来源:origin: jeasonlzy/okhttp-OkGo
/**
* Unlinks interior Node p with predecessor trail.
*/
void unlink(Node<E> p, Node<E> trail) {
// assert isFullyLocked();
// p.next is not changed, to allow iterators that are
// traversing p to maintain their weak-consistency guarantee.
p.setValue(null);
trail.next = p.next;
if (last == p) last = trail;
if (count.getAndDecrement() == capacity) notFull.signal();
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected synchronized void release() {
if (wifiManager != null) {
shadowOf(wifiManager).activeLockCount.getAndDecrement();
}
if (refCounted) {
if (--refCount < 0) throw new RuntimeException("WifiLock under-locked");
} else {
locked = false;
}
}
代码示例来源:origin: mrniko/netty-socketio
@Override
public void onSuccess(T result) {
counter.getAndDecrement();
onClientSuccess(client, result);
executeSuccess();
}
代码示例来源:origin: neo4j/neo4j
@Override
public void fulfill( AvailabilityRequirement requirement )
{
if ( !blockingRequirements.remove( requirement ) )
{
return;
}
synchronized ( requirementCount )
{
if ( requirementCount.getAndDecrement() == 1 && !isShutdown.get() )
{
log.info( DATABASE_AVAILABLE_MSG, requirement.description(), databaseName );
listeners.notify( AvailabilityListener::available );
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(Subscriber<? super String> t1) {
t1.onSubscribe(new BooleanSubscription());
System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis()));
last = System.currentTimeMillis();
if (count.getAndDecrement() == 0) {
t1.onNext("hello");
t1.onComplete();
} else {
t1.onError(new RuntimeException());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
long nr = 0;
try {
while (!terminate.get()) {
Thread.sleep(emitDelay);
if (nextBeforeFailure.getAndDecrement() > 0) {
observer.onNext(nr++);
} else {
active.decrementAndGet();
observer.onError(new RuntimeException("expected-failed"));
break;
}
}
} catch (InterruptedException t) {
}
}
};
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() {
long nr = 0;
try {
while (!terminate.get()) {
Thread.sleep(emitDelay);
if (nextBeforeFailure.getAndDecrement() > 0) {
subscriber.onNext(nr++);
} else {
active.decrementAndGet();
subscriber.onError(new RuntimeException("expected-failed"));
break;
}
}
} catch (InterruptedException t) {
}
}
};
代码示例来源:origin: twitter/distributedlog
@Override
public void notifyReleased(Stream stream) {
acquiredPartitions.removePartition(stream.getPartition());
if (acquiredStreams.remove(stream.getStreamName(), stream)) {
numAcquired.getAndDecrement();
}
}
代码示例来源:origin: netty/netty
/**
* Should be called if the Thread that uses this cache is about to exist to release resources out of the cache
*/
void free() {
// As free() may be called either by the finalizer or by FastThreadLocal.onRemoval(...) we need to ensure
// we only call this one time.
if (freed.compareAndSet(false, true)) {
int numFreed = free(tinySubPageDirectCaches) +
free(smallSubPageDirectCaches) +
free(normalDirectCaches) +
free(tinySubPageHeapCaches) +
free(smallSubPageHeapCaches) +
free(normalHeapCaches);
if (numFreed > 0 && logger.isDebugEnabled()) {
logger.debug("Freed {} thread-local buffer(s) from thread: {}", numFreed,
Thread.currentThread().getName());
}
if (directArena != null) {
directArena.numThreadCaches.getAndDecrement();
}
if (heapArena != null) {
heapArena.numThreadCaches.getAndDecrement();
}
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void subscribe(Observer<? super String> t1) {
t1.onSubscribe(Disposables.empty());
System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis()));
last = System.currentTimeMillis();
if (count.getAndDecrement() == 0) {
t1.onNext("hello");
t1.onComplete();
} else {
t1.onError(new RuntimeException());
}
}
代码示例来源:origin: apache/pulsar
void checkProgrammedFail() throws KeeperException {
if (stepsToFail.getAndDecrement() == 0 || this.alwaysFail) {
throw KeeperException.create(failReturnCode);
}
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void writeToSocket(TcpDiscoveryAbstractMessage msg, Socket sock, int res,
long timeout) throws IOException {
if (msg instanceof TcpDiscoveryJoinRequestMessage && failJoinReqRes.getAndDecrement() > 0)
res = RES_WAIT;
super.writeToSocket(msg, sock, res, timeout);
}
代码示例来源:origin: apache/kafka
@Override
protected boolean flush(ByteBuffer buf) throws IOException {
if (numFlushesRemaining.decrementAndGet() == 0 && !ready())
flushFailureAction.run();
else if (numDelayedFlushesRemaining.getAndDecrement() != 0)
return false;
resetDelayedFlush();
return super.flush(buf);
}
内容来源于网络,如有侵权,请联系作者删除!