fork-join

Handle error in forkJoin on subscribe

旧巷老猫 提交于 2019-12-11 12:15:13
问题 I have next function: saveTable() { ... let promises = []; for (index = 0; index < this._TOTAL.length; ++index) { let promise = this.db.object(ref).update(this._TOTAL[index]); promises.push(promise); } Observable.forkJoin(promises).subscribe(() => { this.messagesService.createMessage('success', `Saved`); this.router.navigate(['/dashboard/my-calculations']); }) } How can i handle error in this case? Actually, i just need to use then and catch after all my promises resolve, so using forkJoin

Resources: Parallelism in Java for OpenGL realtime applications

天涯浪子 提交于 2019-12-11 09:27:39
问题 I recently went to a lecture on the benefits of Parallelism in regards to tapping the power of multicore processors more efficiently for real time 3d graphics applications. This discussion was about C++ and TBB (Threading Building Blocks) (Intel). I have found out about Fork/Join in Java 7 but I would like to learn more about running realtime 3d graphics through OpenGL / JOGL. I have heard that OpenGL/JOGL must exist in one thread. I do not know if this is true. If you have experience with

Java 7 ForkJoinTask and Akka 2.0

别说谁变了你拦得住时间么 提交于 2019-12-11 05:35:52
问题 Is there any plan to leverage java 7 util.concurrent's ForkJoin APIs or, expose similar API in Akka? 回答1: We've been working with Doug Lea to improve ForkJoinPool for Akka, and I'm going to embed the new version for Akka 2.0: http://www.assembla.com/spaces/akka/tickets/1728 Read this for a summary from Doug: http://cs.oswego.edu/pipermail/concurrency-interest/2012-January/008987.html But we won't be exposing the raw API of ForkJoin, that's what the ForkJoin framework is for. Cheers, √ 来源:

Typescript typing error with forkJoin

微笑、不失礼 提交于 2019-12-11 04:05:10
问题 I'm experiencing a TypeScript type check failure when using the forkJoin operator form RxJS. This is the code in question: let products = this.http.get(productUrl, { headers: this.headers }) .map(response => response.json().data as Product[]); let loans = Observable.of(loan); return Observable.forkJoin([products, loans]) .map(data => { let resultProducts = data[0] as Product[]; if (resultProducts.length > 0) { lead.Product = resultProducts.find(i => i.ID == productId); } lead.Loan = data[1];

How to determine the proper work division threshold of a fork-join task

不打扰是莪最后的温柔 提交于 2019-12-10 20:55:04
问题 After looking the Fork/Join Tutorial, I created a class for computing large factorials: public class ForkFactorial extends RecursiveTask<BigInteger> { final int end; final int start; private static final int THRESHOLD = 10; public ForkFactorial(int n) { this(1, n + 1); } private ForkFactorial(int start, int end) { this.start = start; this.end = end; } @Override protected BigInteger compute() { if (end - start < THRESHOLD) { return computeDirectly(); } else { int mid = (start + end) / 2;

A simple list.parallelStream() in java 8 stream does not seem to do work stealing?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 16:43:35
问题 From this question " Will inner parallel streams be processed fully in parallel before considering parallelizing outer stream?", I understood that streams perform work-stealing. However, I've noticed that it often doesn't seem to occur. For example, if I have a List of say 100,000 elements and I attempt to process it in parallelStream() fashion, I often notice towards the end that most of my CPU cores are sitting idle in the "waiting" state. (Note: Of the 100,000 elements in the list, some

RxJS Map array to observable and back to plain object in array

≯℡__Kan透↙ 提交于 2019-12-10 15:38:37
问题 I have an array of objects from which I need to pass each object separately into async method (process behind is handled with Promise and then converted back to Observable via Observable.fromPromise(...) - this way is needed because the same method is used in case just single object is passed anytime; the process is saving objects into database). For example, this is an array of objects: [ { "name": "John", ... }, { "name": "Anna", ... }, { "name": "Joe",, ... }, { "name": "Alexandra", ... },

RxJS Angular2 handling 404 in Observable.forkjoin

喜欢而已 提交于 2019-12-10 14:28:54
问题 I'm currently chaining a bunch of http requests, however I am having trouble handling 404 errors before subscribing. My code: in template: ... service.getData().subscribe( data => this.items = data, err => console.log(err), () => console.log("Get data complete") ) ... in service: ... getDataUsingUrl(url) { return http.get(url).map(res => res.json()); } getData() { return getDataUsingUrl(urlWithData).flatMap(res => { return Observable.forkJoin( // make http request for each element in res res

A light weight Scala fork join syntax

时光总嘲笑我的痴心妄想 提交于 2019-12-10 10:30:22
问题 Despite the upcoming java 7 standard fork/join framework, I am building some helper method that is light weight in syntax for client to run code in parallel. Here is a runnable main method to illustrate the idea. import actors.Futures object ForkTest2 { def main(args: Array[String]) { test1 test2 } def test1 { val (a, b, c) =fork({ Thread.sleep(500) println("inside fx1 ",+System.currentTimeMillis) true }, { Thread.sleep(1000) println("inside fx2 ",+System.currentTimeMillis) "stringResult" },

Why a parallelism ForkJoinPool double my exception?

三世轮回 提交于 2019-12-09 00:09:00
问题 assuming I have the code like as below: Future<Object> executeBy(ExecutorService executor) { return executor.submit(() -> { throw new IllegalStateException(); }); } there is no problem when using ForkJoinPool#commonPool , but when I using a parallelism ForkJoinPool it will double the IllegalStateException . for example: executeBy(new ForkJoinPool(1)).get(); // ^--- double the IllegalStateException Q1 : why the parallelism ForkJoinPool double the Exception occurs in the Callable ? Q2 : how to