BEAL-572 make examples simpler
This commit is contained in:
parent
51d8c0cdb7
commit
c8d818c2f5
|
@ -26,7 +26,7 @@ public class ComputeFunction {
|
|||
|
||||
public static void compute(Observable<Integer> v) {
|
||||
try {
|
||||
System.out.println("compute integer v: " + v);
|
||||
v.forEach(System.out::println);
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -7,7 +7,6 @@ public class HotObservableBackPressureBatching {
|
|||
public static void main(String[] args) throws InterruptedException {
|
||||
PublishSubject<Integer> source = PublishSubject.<Integer>create();
|
||||
|
||||
//buffer
|
||||
source.window(500)
|
||||
.observeOn(Schedulers.computation())
|
||||
.subscribe(ComputeFunction::compute, Throwable::printStackTrace);
|
||||
|
|
|
@ -8,7 +8,6 @@ public class HotObservableBackPressureBuffering {
|
|||
public static void main(String[] args) throws InterruptedException {
|
||||
PublishSubject<Integer> source = PublishSubject.<Integer>create();
|
||||
|
||||
//buffer
|
||||
source
|
||||
.buffer(1024)
|
||||
.observeOn(Schedulers.computation())
|
||||
|
|
|
@ -9,12 +9,8 @@ public class HotObservableBackPressureSkipping {
|
|||
public static void main(String[] args) throws InterruptedException {
|
||||
PublishSubject<Integer> source = PublishSubject.<Integer>create();
|
||||
|
||||
//buffer
|
||||
source
|
||||
// .debounce(1, TimeUnit.SECONDS)
|
||||
// .sample(1, TimeUnit.SECONDS)
|
||||
// .throttleFirst(100, TimeUnit.MILLISECONDS)
|
||||
.throttleLast(100, TimeUnit.MILLISECONDS)
|
||||
source.sample(100, TimeUnit.MILLISECONDS)
|
||||
// .throttleFirst(100, TimeUnit.MILLISECONDS)
|
||||
.observeOn(Schedulers.computation())
|
||||
.subscribe(ComputeFunction::compute, Throwable::printStackTrace);
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import rx.BackpressureOverflow;
|
|||
import rx.Observable;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class HotObservableOnBackPressure {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
Observable.range(1, 1_000_000)
|
||||
|
@ -18,9 +16,8 @@ public class HotObservableOnBackPressure {
|
|||
}, Throwable::printStackTrace);
|
||||
|
||||
|
||||
Observable.interval(1, TimeUnit.MINUTES)
|
||||
Observable.range(1, 1_000_000)
|
||||
.onBackpressureDrop()
|
||||
// .onBackpressureLatest()
|
||||
.observeOn(Schedulers.io())
|
||||
.doOnNext(ComputeFunction::compute)
|
||||
.subscribe(v -> {
|
||||
|
|
|
@ -8,9 +8,8 @@ public class HotObservableWithoutBackPressure {
|
|||
public static void main(String[] args) throws InterruptedException {
|
||||
PublishSubject<Integer> source = PublishSubject.<Integer>create();
|
||||
|
||||
//buffer
|
||||
source.observeOn(Schedulers.computation())
|
||||
.subscribe(ComputeFunction::compute, Throwable::printStackTrace);
|
||||
.subscribe(ComputeFunction::compute, Throwable::printStackTrace);
|
||||
|
||||
|
||||
for (int i = 0; i < 1_000_000; i++) {
|
||||
|
|
Loading…
Reference in New Issue