diff --git a/cartographer/common/internal/testing/thread_pool_for_testing.cc b/cartographer/common/internal/testing/thread_pool_for_testing.cc index 28dbbaa..f804e13 100644 --- a/cartographer/common/internal/testing/thread_pool_for_testing.cc +++ b/cartographer/common/internal/testing/thread_pool_for_testing.cc @@ -53,12 +53,6 @@ void ThreadPoolForTesting::NotifyDependenciesCompleted(Task* task) { tasks_not_ready_.erase(it); } -void ThreadPoolForTesting::Schedule(const std::function& work_item) { - auto task = common::make_unique(); - task->SetWorkItem(work_item); - Schedule(std::move(task)); -} - std::weak_ptr ThreadPoolForTesting::Schedule(std::unique_ptr task) { std::shared_ptr shared_task; { diff --git a/cartographer/common/internal/testing/thread_pool_for_testing.h b/cartographer/common/internal/testing/thread_pool_for_testing.h index 972a1ff..53bccb3 100644 --- a/cartographer/common/internal/testing/thread_pool_for_testing.h +++ b/cartographer/common/internal/testing/thread_pool_for_testing.h @@ -34,18 +34,18 @@ class ThreadPoolForTesting : public ThreadPoolInterface { ThreadPoolForTesting(); ~ThreadPoolForTesting(); - void NotifyDependenciesCompleted(Task* task) EXCLUDES(mutex_) override; - - void Schedule(const std::function& work_item) override; - std::weak_ptr Schedule(std::unique_ptr task) EXCLUDES(mutex_) override; void WaitUntilIdle(); private: + friend class Task; + void DoWork(); + void NotifyDependenciesCompleted(Task* task) EXCLUDES(mutex_) override; + Mutex mutex_; bool running_ GUARDED_BY(mutex_) = true; bool idle_ GUARDED_BY(mutex_) = true; diff --git a/cartographer/common/task_test.cc b/cartographer/common/task_test.cc index e7a3212..249bc08 100644 --- a/cartographer/common/task_test.cc +++ b/cartographer/common/task_test.cc @@ -41,10 +41,6 @@ class FakeThreadPool : public ThreadPoolInterface { tasks_not_ready_.erase(it); } - void Schedule(const std::function& work_item) override { - LOG(FATAL) << "not implemented"; - } - std::weak_ptr Schedule(std::unique_ptr task) override { std::shared_ptr shared_task; auto it = diff --git a/cartographer/common/thread_pool.cc b/cartographer/common/thread_pool.cc index e21d784..bc3c743 100644 --- a/cartographer/common/thread_pool.cc +++ b/cartographer/common/thread_pool.cc @@ -63,12 +63,6 @@ void ThreadPool::NotifyDependenciesCompleted(Task* task) { tasks_not_ready_.erase(it); } -void ThreadPool::Schedule(const std::function& work_item) { - auto task = make_unique(); - task->SetWorkItem(work_item); - Schedule(std::move(task)); -} - std::weak_ptr ThreadPool::Schedule(std::unique_ptr task) { std::shared_ptr shared_task; { diff --git a/cartographer/common/thread_pool.h b/cartographer/common/thread_pool.h index 6dc1114..b3bb595 100644 --- a/cartographer/common/thread_pool.h +++ b/cartographer/common/thread_pool.h @@ -36,8 +36,6 @@ class ThreadPoolInterface { public: ThreadPoolInterface() {} virtual ~ThreadPoolInterface() {} - // TODO(gaschler): Use Schedule(unique_ptr), then remove Schedule. - virtual void Schedule(const std::function& work_item) = 0; virtual std::weak_ptr Schedule(std::unique_ptr task) = 0; protected: @@ -64,9 +62,6 @@ class ThreadPool : public ThreadPoolInterface { ThreadPool(const ThreadPool&) = delete; ThreadPool& operator=(const ThreadPool&) = delete; - // TODO(gaschler): Remove all uses. - void Schedule(const std::function& work_item) override; - // When the returned weak pointer is expired, 'task' has certainly completed, // so dependants no longer need to add it as a dependency. std::weak_ptr Schedule(std::unique_ptr task)