本文整理汇总了Java中rx.internal.util.RxRingBuffer.isCompleted方法的典型用法代码示例。如果您正苦于以下问题:Java RxRingBuffer.isCompleted方法的具体用法?Java RxRingBuffer.isCompleted怎么用?Java RxRingBuffer.isCompleted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.internal.util.RxRingBuffer
的用法示例。
在下文中一共展示了RxRingBuffer.isCompleted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pollTopItem
import rx.internal.util.RxRingBuffer; //导入方法依赖的package包/类
/**
* Polls a top item from the priority queue. Adds the top source back to
* pending set. Not synchronized as accessed inside COUNTER_UPDATER block
*
* @param pending
* set of source observers pending a value for the merge
* @return true if we need a shutdown
*/
private boolean pollTopItem(Set<InnerSubscriber> pending) {
// get a next item in order from the priority queue
ValueSourcePair tuple = queue.poll();
T value = tuple.value;
InnerSubscriber observer = tuple.source;
// mark the wining observer as pending again
pending.add(observer);
try {
// emit the next item in order
child.onNext(value);
// we emitted so decrement the requested counter
requested.decrementAndGet();
observer.emitted++;
} catch (Throwable e) {
Exceptions.throwOrReport(e, child, value);
return true;
}
// now remove
RxRingBuffer buffer = observer.items;
buffer.poll();
// eagerly check if the next item on this queue is an onComplete
if (buffer.isCompleted(buffer.peek())) {
// we need to unsubscribe and remove from pending
pending.remove(observer);
childSubscription.remove(observer);
if (!childSubscription.hasSubscriptions()) {
// it is last upstream observer so onComplete so shut down
child.onCompleted();
return true;
}
return false; // dont request for this observer
}
if (observer.emitted > THRESHOLD) {
observer.requestMore(observer.emitted);
observer.emitted = 0;
}
return false;
}
示例2: tick
import rx.internal.util.RxRingBuffer; //导入方法依赖的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;
}
}
}
}
示例3: pickPendingItems
import rx.internal.util.RxRingBuffer; //导入方法依赖的package包/类
/**
* Tries to pick items from pending sources. Not synchronized as accessed
* inside COUNTER_UPDATER block
*
* @param pending
* set of source observers pending a value for the merge
* @return true if we need a shutdown
*/
boolean pickPendingItems(Set<InnerSubscriber> pending) {
// peek for a potential onCompleted event
for (Iterator<InnerSubscriber> iter = pending.iterator(); iter.hasNext();) {
InnerSubscriber subscr = iter.next();
if (subscr.isUnsubscribed()) {
// we should remove completed observer from the pending set
iter.remove();
}
RxRingBuffer buffer = subscr.items;
Object n = buffer.peek();
if (n == null) {
// we should keep this observer as pending
continue;
}
if (buffer.isCompleted(n)) {
iter.remove();
// this observer indicates completion - unsubscribe and remove from
// pending
childSubscription.remove(subscr);
if (!childSubscription.hasSubscriptions()) {
// it is last upstream observer so onComplete so shut down
child.onCompleted();
return true;
}
} else {
// got new data add to the priority queue and remove from pending set
@SuppressWarnings("unchecked")
T value = (T) buffer.getValue(n);
ValueSourcePair tuple = new ValueSourcePair(value, subscr);
queue.add(tuple);
// remove from pending set
iter.remove();
}
}
return false;
}