Refine search
private static void endCount(RpcStatus status, long elapsed, boolean succeeded) { status.active.decrementAndGet(); status.total.incrementAndGet(); status.totalElapsed.addAndGet(elapsed); if (status.maxElapsed.get() < elapsed) { status.maxElapsed.set(elapsed); } if (succeeded) { if (status.succeededMaxElapsed.get() < elapsed) { status.succeededMaxElapsed.set(elapsed); } } else { status.failed.incrementAndGet(); status.failedElapsed.addAndGet(elapsed); if (status.failedMaxElapsed.get() < elapsed) { status.failedMaxElapsed.set(elapsed); } } }
WindowOverlapSubscriber(Subscriber<? super Flowable<T>> actual, long size, long skip, int bufferSize) { super(1); this.downstream = actual; this.size = size; this.skip = skip; this.queue = new SpscLinkedArrayQueue<UnicastProcessor<T>>(bufferSize); this.windows = new ArrayDeque<UnicastProcessor<T>>(); this.once = new AtomicBoolean(); this.firstRequest = new AtomicBoolean(); this.requested = new AtomicLong(); this.wip = new AtomicInteger(); this.bufferSize = bufferSize; }
/** * Acquire the light lock protecting this consumer from multi-threaded access. Instead of blocking * when the lock is not available, however, we just throw an exception (since multi-threaded usage is not * supported). * @throws ConcurrentModificationException if another thread already has the lock */ private void acquire() { long threadId = Thread.currentThread().getId(); if (threadId != currentThread.get() && !currentThread.compareAndSet(NO_CURRENT_THREAD, threadId)) throw new ConcurrentModificationException("KafkaConsumer is not safe for multi-threaded access"); refcount.incrementAndGet(); }
@Override public UUID generateId() { long leastSigBits = this.leastSigBits.incrementAndGet(); if (leastSigBits == 0) { this.mostSigBits.incrementAndGet(); } return new UUID(this.mostSigBits.get(), leastSigBits); }
/** * Atomically adds the positive value n to the requested value in the AtomicLong and * caps the result at Long.MAX_VALUE and returns the previous value. * @param requested the AtomicLong holding the current requested value * @param n the value to add, must be positive (not verified) * @return the original value before the add */ public static long add(AtomicLong requested, long n) { for (;;) { long r = requested.get(); if (r == Long.MAX_VALUE) { return Long.MAX_VALUE; } long u = addCap(r, n); if (requested.compareAndSet(r, u)) { return r; } } }
FlatMapMaybeSubscriber(Subscriber<? super R> actual, Function<? super T, ? extends MaybeSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency) { this.downstream = actual; this.mapper = mapper; this.delayErrors = delayErrors; this.maxConcurrency = maxConcurrency; this.requested = new AtomicLong(); this.set = new CompositeDisposable(); this.errors = new AtomicThrowable(); this.active = new AtomicInteger(1); this.queue = new AtomicReference<SpscLinkedArrayQueue<R>>(); }
@Test(timeout = 2000) public void testUnsubscribeFromSynchronousInfiniteObservable() { final AtomicLong count = new AtomicLong(); INFINITE_OBSERVABLE.take(10).subscribe(new Consumer<Long>() { @Override public void accept(Long l) { count.set(l); } }); assertEquals(10, count.get()); }
@Override public void accept(Disposable d) { count.incrementAndGet(); } };
public void afterInvoke(Throwable error, long nanos) { runningCount.decrementAndGet(); executeTimeNano.addAndGet(nanos); histogramRecord(nanos); if (error != null) { executeErrorCount.incrementAndGet(); lastError = error; lastErrorTimeMillis = System.currentTimeMillis(); } Profiler.release(nanos); }
public void testForEach() { ImmutableLongArray.of().forEach(i -> fail()); ImmutableLongArray.of(0, 1, 3).subArray(1, 1).forEach(i -> fail()); AtomicLong count = new AtomicLong(0); ImmutableLongArray.of(0, 1, 2, 3) .forEach(i -> assertThat(i).isEqualTo(count.getAndIncrement())); assertEquals(4, count.get()); }
@Override public void request(long n) { requested.set(n); }
FlatMapIterableObserver(Subscriber<? super R> actual, Function<? super T, ? extends Iterable<? extends R>> mapper) { this.downstream = actual; this.mapper = mapper; this.requested = new AtomicLong(); }
@Override public final long produced(long n) { return requested.addAndGet(-n); }
/** * Release the light lock protecting the consumer from multi-threaded access. */ private void release() { if (refcount.decrementAndGet() == 0) currentThread.set(NO_CURRENT_THREAD); }
@Override public EventListener create(Call call) { long callId = nextCallId.getAndIncrement(); System.out.printf("%04d %s%n", callId, call.request().url()); return new PrintingEventListener(callId, System.nanoTime()); } };
public void afterExecute(long nanoSpan) { runningCount.decrementAndGet(); nanoTotal.addAndGet(nanoSpan); long millis = nanoSpan / (1000 * 1000); histogram.record(millis); }
@Override public void onTimeoutError(long idx, Throwable ex) { if (index.compareAndSet(idx, Long.MAX_VALUE)) { DisposableHelper.dispose(this); downstream.onError(ex); } else { RxJavaPlugins.onError(ex); } }
FlatMapSingleSubscriber(Subscriber<? super R> actual, Function<? super T, ? extends SingleSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency) { this.downstream = actual; this.mapper = mapper; this.delayErrors = delayErrors; this.maxConcurrency = maxConcurrency; this.requested = new AtomicLong(); this.set = new CompositeDisposable(); this.errors = new AtomicThrowable(); this.active = new AtomicInteger(1); this.queue = new AtomicReference<SpscLinkedArrayQueue<R>>(); }