X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=pctb%2Fpages.c;fp=pctb%2Fpages.c;h=1a9970162ce10c8fd667208b5476f1ca9cde44f8;hp=008116197046760211651d4b09af889631ac7f8e;hb=c66cfd9d90974888907605f6d9888bcadd5fa433;hpb=a5027ece716333370b103b7356582f7ef87ef3cf diff --git a/pctb/pages.c b/pctb/pages.c index 0081161..1a99701 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -321,6 +321,7 @@ static void wait_for_stability(Snapshot **output, va_start(al,fmt); Snapshot *last=0; + int nidentical=0; /* waits longer if we're going to return an image identical to previously * if previously==0, all images are considered identical to it */ @@ -333,33 +334,33 @@ static void wait_for_stability(Snapshot **output, last_input, previously, doing); for (;;) { - double at_snapshot= timestamp(); - double need_sleep= min_update_allowance - (at_snapshot - last_input); - if (need_sleep > 0) { delay(need_sleep); continue; } - + usleep(250000); snapshot(output); - if (!with_keypress && - !(previously && identical(*output,previously))) { - debugf("PAGING wait_for_stability simple\n"); - break; - } - - if (last && identical(*output,last)) { - debugf("PAGING wait_for_stability stabilised\n"); - break; + if (!last) { + debugf("PAGING wait_for_stability first...\n"); + last=*output; *output=0; + } else if (!identical(*output,last)) { + debugf("PAGING wait_for_stability changed...\n"); + free(last); last=*output; *output=0; + nidentical=0; + } else { + nidentical++; + int threshold= + !previously ? 3 : + identical(*output,previously) ? 3 + : 1; + debugf("PAGING wait_for_stability nidentical=%d threshold=%d\n", + nidentical, threshold); + if (nidentical >= threshold) + break; } - progress_spinner("%s",doing); - debugf("PAGING wait_for_stability retry\n"); - - free_snapshot(&last); last=*output; *output=0; - if (with_keypress) with_keypress(); - delay(0.5); + usleep(250000); } free_snapshot(&last);