Debian Codegraph @

src/jmh/java/io/reactivex/rxjava3/core/PerfInteropConsumer.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.core;
15
16 import org.openjdk.jmh.infra.Blackhole;
17 import org.reactivestreams.*;
18
19 import io.reactivex.rxjava3.disposables.Disposable;
20
21 /**
22 * A multi-type synchronous consumer that doesn't implement FlowableSubscriber and
23 * thus should be treated by Flowable as a candidate for strict interop.
24 */
25 public final class PerfInteropConsumer implements Subscriber<Object>, Observer<Object>,
26 SingleObserver<Object>, CompletableObserver, MaybeObserver<Object> {
27
28 final Blackhole bh;
29
30 public PerfInteropConsumer(Blackhole bh) {
31 this.bh = bh;
32 }
33
34 @Override
35 public void onSuccess(Object value) {
36 bh.consume(value);
37 }
38
39 @Override
40 public void onSubscribe(Disposable d) {
41 }
42
43 @Override
44 public void onSubscribe(Subscription s) {
45 s.request(Long.MAX_VALUE);
46 }
47
48 @Override
49 public void onNext(Object t) {
50 bh.consume(t);
51 }
52
53 @Override
54 public void onError(Throwable t) {
55 t.printStackTrace();
56 }
57
58 @Override
59 public void onComplete() {
60 bh.consume(true);
61 }
62 }