1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2024-10-27 20:34:20 +00:00

laminarc: correct variable lifetime of show-jobs etc

the one-liner used to iterate on the results of the RPC
calls for show-jobs, show-queued and show-running meant
that the result collection was destroyed before we
finished with it. Hoist it out of the loop.

resolves #127
This commit is contained in:
Oliver Giles 2020-06-14 07:48:52 +12:00
parent 6c61fb3111
commit 081becf23a

View File

@ -191,7 +191,8 @@ int main(int argc, char** argv) {
fprintf(stderr, "Usage: %s show-jobs\n", argv[0]); fprintf(stderr, "Usage: %s show-jobs\n", argv[0]);
return EXIT_BAD_ARGUMENT; return EXIT_BAD_ARGUMENT;
} }
for(auto it : laminar.listKnownRequest().send().wait(waitScope).getResult()) { auto jobs = laminar.listKnownRequest().send().wait(waitScope);
for(auto it : jobs.getResult()) {
printf("%s\n", it.cStr()); printf("%s\n", it.cStr());
} }
} else if(strcmp(argv[1], "show-queued") == 0) { } else if(strcmp(argv[1], "show-queued") == 0) {
@ -199,7 +200,8 @@ int main(int argc, char** argv) {
fprintf(stderr, "Usage: %s show-queued\n", argv[0]); fprintf(stderr, "Usage: %s show-queued\n", argv[0]);
return EXIT_BAD_ARGUMENT; return EXIT_BAD_ARGUMENT;
} }
for(auto it : laminar.listQueuedRequest().send().wait(waitScope).getResult()) { auto queued = laminar.listQueuedRequest().send().wait(waitScope);
for(auto it : queued.getResult()) {
printf("%s\n", it.cStr()); printf("%s\n", it.cStr());
} }
} else if(strcmp(argv[1], "show-running") == 0) { } else if(strcmp(argv[1], "show-running") == 0) {
@ -207,7 +209,8 @@ int main(int argc, char** argv) {
fprintf(stderr, "Usage: %s show-running\n", argv[0]); fprintf(stderr, "Usage: %s show-running\n", argv[0]);
return EXIT_BAD_ARGUMENT; return EXIT_BAD_ARGUMENT;
} }
for(auto it : laminar.listRunningRequest().send().wait(waitScope).getResult()) { auto running = laminar.listRunningRequest().send().wait(waitScope);
for(auto it : running.getResult()) {
printf("%s:%d\n", it.getJob().cStr(), it.getBuildNum()); printf("%s:%d\n", it.getJob().cStr(), it.getBuildNum());
} }
} else { } else {