Always flush sfen writer at the end of gensfen and when it is destroyed.

This commit is contained in:
Tomasz Sobczyk
2020-10-24 22:30:08 +02:00
committed by nodchip
parent 21fac7c53c
commit d77b3d176e
+13 -3
View File
@@ -61,6 +61,8 @@ namespace Learner
~SfenWriter() ~SfenWriter()
{ {
flush();
finished = true; finished = true;
file_worker_thread.join(); file_worker_thread.join();
output_file_stream.reset(); output_file_stream.reset();
@@ -105,8 +107,16 @@ namespace Learner
} }
} }
void flush()
{
for (size_t i = 0; i < sfen_buffers.size(); ++i)
{
flush(i);
}
}
// Move what remains in the buffer for your thread to a buffer for writing to a file. // Move what remains in the buffer for your thread to a buffer for writing to a file.
void finalize(size_t thread_id) void flush(size_t thread_id)
{ {
std::unique_lock<std::mutex> lk(mutex); std::unique_lock<std::mutex> lk(mutex);
@@ -357,6 +367,8 @@ namespace Learner
}); });
Threads.wait_for_workers_finished(); Threads.wait_for_workers_finished();
sfen_writer.flush();
if (limit % REPORT_STATS_EVERY != 0) if (limit % REPORT_STATS_EVERY != 0)
{ {
report(limit, limit % REPORT_STATS_EVERY); report(limit, limit % REPORT_STATS_EVERY);
@@ -842,8 +854,6 @@ namespace Learner
} }
} }
sfen_writer.finalize(th.thread_idx());
} }
void set_gensfen_search_limits() void set_gensfen_search_limits()