static ItIt<Pair<S, Int>> returnCodesOfMultipleServers_parallel_iterator(int timeout, S... servers) {
ret returnCodesOfMultipleServers_parallel_iterator(timeout, asList(servers));
}
static ItIt<Pair<S, Int>> returnCodesOfMultipleServers_parallel_iterator(final int timeout, final Collection<S> servers) {
final Var<Int> counter = new(0);
final L<Pair<S, Int>> results = synchroList();
// Fire up the threads (with timeouts)
for (fS server : servers)
thread "Server Check" {
results.add(pair(server, returnCodeHttpHEADWithTimeout(timeout, server)));
syncIncIntVar(counter);
}
// Make iterator delivering results as they come in
ret iteratorFromFunction(new F0<Pair<S, Int>>() {
int n = 0;
public Pair<S, Int> get() {
if (n >= l(servers)) null;
waitForVarToChange(counter, n);
ret results.get(n++);
}
});
}
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: | 826 / 839 |
| Version history: | 7 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1018973 - returnCodesOfServers_parallel_withTime |