Skip to content

Commit 7e3b5c6

Browse files
authored
Merge pull request #242 from bangerth/diff-eval
Make sure we don't forget post-loop actions.
2 parents c978eab + 7adfbc4 commit 7e3b5c6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

include/sampleflow/producers/differential_evaluation_mh.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ namespace SampleFlow
196196
// "generations" and an inner loop over the individual chains. We
197197
// exit from the inner loop when we have reached the desired number of
198198
// samples.
199-
for (types::sample_index generation=0; true; ++generation)
199+
for (types::sample_index generation=0; generation * n_chains < n_samples; ++generation)
200200
{
201201
// A vector that will contain the std::future objects used to
202202
// hold results of either synchronous or asynchronous
@@ -315,11 +315,10 @@ namespace SampleFlow
315315
// guarantees a stable order.
316316
for (typename std::vector<OutputType>::size_type chain = 0; chain < n_chains; ++chain)
317317
{
318-
// Return if we have already generated the desired number of
319-
// samples. The ScopeExit object above also makes sure that
320-
// we flush the downstream consumers.
318+
// Break the loop if we have already generated the desired number of
319+
// samples:
321320
if (generation * n_chains + chain >= n_samples)
322-
return;
321+
break;
323322

324323
// Wait for the futures to be ready. Then output the new sample
325324
// (which may of course be equal to the old sample).

0 commit comments

Comments
 (0)