diff options
Diffstat (limited to 'main/src/cgeo/geocaching/utils/RxUtils.java')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/RxUtils.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/utils/RxUtils.java b/main/src/cgeo/geocaching/utils/RxUtils.java index 8e7864c..a5cdc5f 100644 --- a/main/src/cgeo/geocaching/utils/RxUtils.java +++ b/main/src/cgeo/geocaching/utils/RxUtils.java @@ -1,18 +1,23 @@ package cgeo.geocaching.utils; +import rx.Observable; import rx.Scheduler; +import rx.observables.BlockingObservable; import rx.schedulers.Schedulers; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - public class RxUtils { // Utility class, not to be instanciated private RxUtils() {} - final static private int cores = Runtime.getRuntime().availableProcessors(); - public final static Scheduler computationScheduler = Schedulers.executor(new ThreadPoolExecutor(1, cores, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>())); + public final static Scheduler computationScheduler = Schedulers.computation(); + + public static <T> void waitForCompletion(final BlockingObservable<T> observable) { + observable.lastOrDefault(null); + return; + } + public static void waitForCompletion(final Observable<?>... observables) { + waitForCompletion(Observable.merge(observables).toBlockingObservable()); + } } |
