Wait for the stats thread to terminate in interleave destructor.

PiperOrigin-RevId: 290367959
Change-Id: Ief9fe5a194d87575ceb68057ffd497cf854520c6
This commit is contained in:
Andrew Audibert 2020-01-17 16:56:39 -08:00 committed by TensorFlower Gardener
parent 356d83f70b
commit 6fff5dea63

View File

@ -494,6 +494,7 @@ class ParallelInterleaveDatasetOp::Dataset : public DatasetBase {
IncrementOutstandingThreads();
thread_pool_->Schedule([this]() { WorkerManagerThread(); });
if (ctx_->stats_aggregator()) {
IncrementOutstandingThreads();
thread_pool_->Schedule([this]() { StatsThread(); });
}
threads_initialized_ = true;
@ -983,7 +984,8 @@ class ParallelInterleaveDatasetOp::Dataset : public DatasetBase {
l, std::chrono::milliseconds(kStatsReportingPeriodMillis));
}
if (cancelled_) {
break;
DecrementOutstandingThreads();
return;
}
num_current_active_workers = num_current_active_workers_;
num_current_workers = num_current_workers_;