diff options
author | Thomas White <taw@physics.org> | 2010-10-08 14:48:16 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:01 +0100 |
commit | 59df05a16fb0c221905438d7ab3d2dcd9ec81908 (patch) | |
tree | a3a9307836a80407dd4a00242f48305422c471d9 /src | |
parent | 59b806107c0bd532d4f315422547f2aaede460cd (diff) |
facetron: Tidy up result counting
Diffstat (limited to 'src')
-rw-r--r-- | src/facetron.c | 17 |
1 files changed, 11 insertions, 6 deletions
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 */ } } |