diff options
Diffstat (limited to 'tensorflow/core/kernels/data/map_and_batch_dataset_op.cc')
-rw-r--r-- | tensorflow/core/kernels/data/map_and_batch_dataset_op.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc index f45a239793..0fb721cd7c 100644 --- a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc @@ -445,9 +445,10 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { EXCLUSIVE_LOCKS_REQUIRED(*mu_) { if (!runner_thread_) { auto ctx_copy = std::make_shared<IteratorContext>(*ctx); - runner_thread_.reset(ctx->env()->StartThread( - {}, "runner_thread", - std::bind(&Iterator::RunnerThread, this, ctx_copy))); + runner_thread_ = + MakeUnique<BackgroundWorker>(ctx->env(), "runner_thread"); + runner_thread_->Schedule( + std::bind(&Iterator::RunnerThread, this, ctx_copy)); } } @@ -703,7 +704,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { std::unique_ptr<IteratorBase> input_impl_; // Buffer for storing the (intermediate) batch results. std::deque<std::shared_ptr<BatchResult>> batch_results_ GUARDED_BY(*mu_); - std::unique_ptr<Thread> runner_thread_ GUARDED_BY(*mu_); + std::unique_ptr<BackgroundWorker> runner_thread_ GUARDED_BY(*mu_); bool cancelled_ GUARDED_BY(*mu_) = false; }; |