static <A extends Collection<? extends Collection>> L parallelMap(A l, fO f) ctex { ret parallelMap(iterator((Collection) l), f); } static L parallelMap(Iterator<? extends Collection> it, fO f) ctex { final new L<Pair<O, Int>> out; int poolSize = coresToUse(), queueSize = 10; NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS); try { int i = 0; for (fO o : iterable(it)) { ++i; final int _i = i; e.execute(r { pcall { O x = callF(f, o); synchronized(out) { out.add(pair(x, _i)); } }}); } e.shutdown(); e.awaitTermination(1, TimeUnit.DAYS); } finally { e.shutdown(); } ret firstOfPairs(sortBySecondOfPairs_inPlace(out)); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1011925 |
| Snippet name: | parallelMap |
| Eternal ID of this version: | #1011925/8 |
| Text MD5: | 7ca418b27415874df6364888881cf3e5 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-05-14 01:26:51 |
| Source code size: | 801 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 756 / 769 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |