Libraryless. Click here for Pure Java version (2914L/19K).
static <A extends Runnable> void parallelDo(Cl<A> l, O... _) { parallelDo(iterator(l), l(l), _); } static <A extends Runnable> void parallelDo(Iterator<A> it, int count, O... _) ctex { optPar int queueSize = 500; optPar int poolSize = coresToUse_fixed(); NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS); // TODO: if poolSize == 1, do it in this thread new Var<Throwable> error; try { for (A o : iterable(it)) { if (o == null) continue; e.execute(r { pcall { try { o.run(); } catch e { error.set(e); } }}); } e.shutdown(); e.awaitTermination(1, TimeUnit.DAYS); } finally { e.shutdown(); } if (error.has()) throw rethrow(error!); }
Began life as a copy of #1015446
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1029432 |
| Snippet name: | parallelDo |
| Eternal ID of this version: | #1029432/5 |
| Text MD5: | fb8e67bbf3eb8d80d7796b29d3c69ff7 |
| Transpilation MD5: | 4d33132c67683b3594d41619cbf19dab |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-08-06 18:45:46 |
| Source code size: | 809 bytes / 32 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 470 / 600 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |