1 | static ItIt<Pair<S, Int>> returnCodesOfMultipleServers_parallel_iterator(int timeout, S... servers) { |
2 | ret returnCodesOfMultipleServers_parallel_iterator(timeout, asList(servers)); |
3 | } |
4 | |
5 | static ItIt<Pair<S, Int>> returnCodesOfMultipleServers_parallel_iterator(final int timeout, final Collection<S> servers) { |
6 | final Var<Int> counter = new(0); |
7 | final L<Pair<S, Int>> results = synchroList(); |
8 | |
9 | // Fire up the threads (with timeouts) |
10 | |
11 | for (fS server : servers) |
12 | thread "Server Check" { |
13 | results.add(pair(server, returnCodeHttpHEADWithTimeout(timeout, server))); |
14 | syncIncIntVar(counter); |
15 | } |
16 | |
17 | // Make iterator delivering results as they come in |
18 | ret iteratorFromFunction(new F0<Pair<S, Int>>() { |
19 | int n = 0; |
20 | |
21 | public Pair<S, Int> get() { |
22 | if (n >= l(servers)) null; |
23 | waitForVarToChange(counter, n); |
24 | ret results.get(n++); |
25 | } |
26 | }); |
27 | } |
Began life as a copy of #1018967
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018972 |
Snippet name: | returnCodesOfMultipleServers_parallel_iterator |
Eternal ID of this version: | #1018972/8 |
Text MD5: | 5268218ceb8517f58e4947bcf560527f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-18 16:51:46 |
Source code size: | 915 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 387 / 432 |
Version history: | 7 change(s) |
Referenced in: | [show references] |