Debian Codegraph @

src/jmh/java/io/reactivex/rxjava3/core/PerfConsumer.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.Subscription;
18
19 import io.reactivex.rxjava3.disposables.Disposable;
20
21 /**
22 * A multi-type synchronous consumer.
23 */
24 public final class PerfConsumer implements FlowableSubscriber<Object>, Observer<Object>,
25 SingleObserver<Object>, CompletableObserver, MaybeObserver<Object> {
26
27 final Blackhole bh;
28
29 public PerfConsumer(Blackhole bh) {
30 this.bh = bh;
31 }
32
33 @Override
34 public void onSuccess(Object value) {
35 bh.consume(value);
36 }
37
38 @Override
39 public void onSubscribe(Disposable d) {
40 }
41
42 @Override
43 public void onSubscribe(Subscription s) {
44 s.request(Long.MAX_VALUE);
45 }
46
47 @Override
48 public void onNext(Object t) {
49 bh.consume(t);
50 }
51
52 @Override
53 public void onError(Throwable t) {
54 t.printStackTrace();
55 }
56
57 @Override
58 public void onComplete() {
59 bh.consume(true);
60 }
61 }