From 59df05a16fb0c221905438d7ab3d2dcd9ec81908 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 8 Oct 2010 14:48:16 +0200 Subject: facetron: Tidy up result counting --- src/facetron.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/facetron.c') diff --git a/src/facetron.c b/src/facetron.c index f7b801e6..486cde6d 100644 --- a/src/facetron.c +++ b/src/facetron.c @@ -207,16 +207,19 @@ static void refine_all(struct image *images, int n_total_patterns, pthread_mutex_unlock(&pargs->control_mutex); if ( !done ) continue; + /* Reset "done" flag */ + pargs->done = 0; + n_done++; progress_bar(n_done, n_total_patterns, "Refining"); - /* Start work on the next pattern */ + /* If there are no more patterns, "done" will remain + * zero, so the last pattern will not be re-counted. */ if ( n_started == n_total_patterns ) break; - pargs->image = &images[n_started++]; - /* Wake the thread up ... */ + /* Start work on the next pattern */ + pargs->image = &images[n_started++]; pthread_mutex_lock(&pargs->control_mutex); - pargs->done = 0; pargs->start = 1; pthread_mutex_unlock(&pargs->control_mutex); @@ -238,8 +241,10 @@ static void refine_all(struct image *images, int n_total_patterns, /* Wait for it to join */ pthread_join(workers[i], NULL); - n_done++; - progress_bar(n_done, n_total_patterns, "Refining"); + if ( pargs->done ) { + n_done++; + progress_bar(n_done, n_total_patterns, "Refining"); + } /* else this thread was not busy */ } } -- cgit v1.2.3