How to access and increase 'rx2.buffer-size' in RxJava 2?

狂风中的少年 提交于 2019-12-13 03:26:29

问题


In http://reactivex.io/RxJava/javadoc/io/reactivex/Observable it is stated:

The Observable's operators, by default, run with a buffer size of 128 elements (see Flowable.bufferSize(), that can be overridden globally via the system parameter rx2.buffer-size.

My question is, how can I access and set rx2.buffer-size? If I do:

import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.Single;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.BehaviorSubject;
import io.reactivex.subjects.PublishSubject;
import io.reactivex.subjects.Subject;
import io.reactivex.*;

...followed by:

Integer bufferSize = rx2.buffer-size;

I am informed by Studio that:

  • Unused import statement (for import io.reactivex.*;)
  • Cannot resolve symbol 'rx2'
  • Cannot resolve symbol 'size'

How can I override the system parameter rx2.buffer-size?

My project is using

io.reactivex.rxjava2/rxandroid/2.0.1
io.reactivex.rxjava2/rxjava/2.1.11

回答1:


Try :

Integer bufferSize = Integer.parseInt(System.getProperty("rx2.buffer-size"))

To set a new value :

System.setProperty("rx2.buffer-size", 2048)


来源:https://stackoverflow.com/questions/52956589/how-to-access-and-increase-rx2-buffer-size-in-rxjava-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!