本文整理汇总了Java中java.util.concurrent.Flow.Subscriber方法的典型用法代码示例。如果您正苦于以下问题:Java Flow.Subscriber方法的具体用法?Java Flow.Subscriber怎么用?Java Flow.Subscriber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.Flow
的用法示例。
在下文中一共展示了Flow.Subscriber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public synchronized void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {
InputStream is = streamSupplier.get();
if (is == null) {
throw new UncheckedIOException(new IOException("no inputstream supplied"));
}
this.delegate = new PullPublisher<>(() -> new StreamIterator(is));
delegate.subscribe(subscriber);
}
示例2: testErredJson
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testErredJson() {
jsonConverter = new JsonConverter();
Flow.Subscription subscription = Mockito.mock(Flow.Subscription.class);
jsonConverter.onSubscribe(subscription);
Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
jsonConverter.subscribe(subscriber);
jsonConverter.onNext("{]".getBytes());
Mockito.verify(subscriber).onError(Mockito.any(IllegalArgumentException.class));
Mockito.verify(subscription).cancel();
}
示例3: testOnErrorShouldDontFireCompletion
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testOnErrorShouldDontFireCompletion() {
Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
jsonConverter.subscribe(subscriber);
jsonConverter.onComplete();
jsonConverter.onError(new Exception());
jsonConverter.onNext("{}".getBytes());
Mockito.verify(subscriber).onError(Mockito.any(Exception.class));
Mockito.verify(subscriber, Mockito.times(0)).onComplete();
}
示例4: testFireErrorIfParsingComplete
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Test
public void testFireErrorIfParsingComplete() {
Flow.Subscriber subscriber = Mockito.mock(Flow.Subscriber.class);
jsonConverter.subscribe(subscriber);
jsonConverter.onNext("{}{}".getBytes());
Mockito.verify(subscriber).onError(Mockito.any(IllegalArgumentException.class));
}
示例5: StreamSubscription
import java.util.concurrent.Flow; //导入方法依赖的package包/类
StreamSubscription(Flow.Subscriber<? super T> subscriber) {
this.subscriber = subscriber;
Iterator<? extends T> iterator = null;
try {
iterator = streamSupplier.get().iterator();
} catch (Throwable e) {
error.set(e);
}
this.iterator = iterator;
}
示例6: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> flow) {
if (flow == null) {
reactiveStreams.subscribe(null);
return;
}
reactiveStreams.subscribe(new ReactiveToFlowSubscriber<T>(flow));
}
示例7: onNext
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public static <T> void onNext(Flow.Subscriber<T> actual, Object target, VarHandle WIP, VarHandle ERRORS, T item) {
if ((int)WIP.getAcquire(target) == 0 && WIP.compareAndSet(target, 0, 1)) {
actual.onNext(item);
if (!WIP.compareAndSet(target, 1, 0)) {
Throwable ex = ExceptionHelper.terminate(target, ERRORS);
if (ex == null) {
actual.onComplete();
} else {
actual.onError(ex);
}
}
}
}
示例8: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
try {
subscriber.onSubscribe(new Subscription(subscriber));
} catch (RejectedExecutionException e) {
subscriber.onError(new IllegalStateException(e));
}
}
示例9: Subscription
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public Subscription(Flow.Subscriber subscriber,
ExecutorService executor) {
this.subscriber = subscriber;
this.executor = executor;
}
示例10: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super String> subscriber) {
this.subscriber = subscriber;
}
示例11: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
subscription = new Subscription(subscriber);
subscriber.onSubscribe(subscription);
}
示例12: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super T> subscriber) {
subscriber.onSubscribe(new Subscription(subscriber));
}
示例13: Subscription
import java.util.concurrent.Flow; //导入方法依赖的package包/类
Subscription(Flow.Subscriber<? super T> subscriber) {
this.subscriber = subscriber;
}
示例14: subscribe
import java.util.concurrent.Flow; //导入方法依赖的package包/类
@Override
public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {
delegate.subscribe(subscriber);
}
示例15: StrictSubscriber
import java.util.concurrent.Flow; //导入方法依赖的package包/类
public StrictSubscriber(Flow.Subscriber<? super T> actual) {
this.actual = actual;
}