Skip to content

Commit ca6237b

Browse files
committed
Always flush currently active Iteration
1 parent 15cb968 commit ca6237b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/Series.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,8 @@ auto Series::openIterationIfDirty(IterationIndex_t index, Iteration &iteration)
27022702
{
27032703
return IterationOpened::RemainsClosed;
27042704
}
2705-
bool const dirtyRecursive = iteration.dirtyRecursive();
2705+
bool dirtyRecursive = iteration.dirtyRecursive();
2706+
27062707
if (data.m_closed == internal::CloseStatus::Closed)
27072708
{
27082709
// file corresponding with the iteration has previously been
@@ -2731,6 +2732,28 @@ auto Series::openIterationIfDirty(IterationIndex_t index, Iteration &iteration)
27312732
}
27322733
}
27332734

2735+
/*
2736+
* When using writeIterations(), the currently active Iteration should
2737+
* always be flushed (unless, as checked above, it is already closed).
2738+
* This block checks if an Iteration is currently collectively opened.
2739+
*/
2740+
[&]() {
2741+
auto &series = get();
2742+
if (!series.m_sharedStatefulIterator)
2743+
{
2744+
return;
2745+
}
2746+
auto &shared_iterator = *series.m_sharedStatefulIterator;
2747+
if (!shared_iterator.m_data || !shared_iterator.m_data->has_value())
2748+
{
2749+
return;
2750+
}
2751+
auto const current_iteration =
2752+
(*shared_iterator.m_data)->currentIteration();
2753+
dirtyRecursive |=
2754+
current_iteration.has_value() && *current_iteration == index;
2755+
}();
2756+
27342757
switch (iterationEncoding())
27352758
{
27362759
using IE = IterationEncoding;

0 commit comments

Comments
 (0)