Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flatMap variant with maxConcurrent #2626

Closed
benjchristensen opened this issue Feb 6, 2015 · 2 comments
Closed

Add flatMap variant with maxConcurrent #2626

benjchristensen opened this issue Feb 6, 2015 · 2 comments

Comments

@benjchristensen
Copy link
Member

To allow use of merge(Observables..., maxConcurrent) via flatMap we should consider adding a flatMap(Func, int maxConcurrent) overload.

@benjchristensen
Copy link
Member Author

Example usage:

        Observable.range(0, Integer.MAX_VALUE).map(i -> "lineOfData-" + i) // simulate the file with many lines
                .buffer(100) // buffer up chunks of work before processing them
                .flatMap(chunk -> {
                    return Observable.just(chunk).subscribeOn(Schedulers.io()) // put each group on a new thread (io scheduler for blocking IO) 
                            .doOnNext(t -> {
                                // do work here
                                try {
                                    Thread.sleep(1000);
                                } catch (Exception e) {
                                }
                                // write out on blocking IO as a side-effect
                                System.out.println("Emitting to IO: " + t);
                            });
                }, maxConcurrentValueHere).toBlocking().forEach(System.out::println);

@akarnokd
Copy link
Member

The related PR has been merged. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants