From: Ian Jackson Date: Sun, 28 Jun 2009 15:06:45 +0000 (+0100) Subject: adjust code from abandon.stability e19af2579b9619071d17d3fba67c2d0e3d225f61 to curren... X-Git-Tag: 1.9.2~90^2~11 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=c66cfd9d90974888907605f6d9888bcadd5fa433 adjust code from abandon.stability e19af2579b9619071d17d3fba67c2d0e3d225f61 to current context, ready for integration --- 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);