25 LOG(WARNING) <<
"Delete Task between dispatch and completion.";
36 CHECK_EQ(state_,
NEW);
37 work_item_ = work_item;
41 std::shared_ptr<Task> shared_dependency;
44 CHECK_EQ(state_,
NEW);
45 if ((shared_dependency = dependency.lock())) {
46 ++uncompleted_dependencies_;
49 if (shared_dependency) {
50 shared_dependency->AddDependentTask(
this);
56 CHECK_EQ(state_,
NEW);
58 thread_pool_to_notify_ = thread_pool;
59 if (uncompleted_dependencies_ == 0) {
61 CHECK(thread_pool_to_notify_);
62 thread_pool_to_notify_->NotifyDependenciesCompleted(
this);
72 bool inserted = dependent_tasks_.insert(dependent_task).second;
73 CHECK(inserted) <<
"Given dependency is already a dependency.";
79 --uncompleted_dependencies_;
80 if (uncompleted_dependencies_ == 0 && state_ ==
DISPATCHED) {
82 CHECK(thread_pool_to_notify_);
83 thread_pool_to_notify_->NotifyDependenciesCompleted(
this);
101 for (
Task* dependent_task : dependent_tasks_) {
102 dependent_task->OnDependenyCompleted();
void SetWorkItem(const WorkItem &work_item) EXCLUDES(mutex_)
std::function< void()> WorkItem
void AddDependency(std::weak_ptr< Task > dependency) EXCLUDES(mutex_)
void OnDependenyCompleted()
State GetState() EXCLUDES(mutex_)
void Execute() EXCLUDES(mutex_)
void SetThreadPool(ThreadPoolInterface *thread_pool) EXCLUDES(mutex_)
Mutex::Locker MutexLocker
void AddDependentTask(Task *dependent_task)