| 223 | } |
| 224 | |
| 225 | Status TaskSchedulerImpl::OnTaskGroupFinished(size_t thread_id, int group_id, |
| 226 | bool* all_task_groups_finished) { |
| 227 | bool aborted = aborted_.value.load(); |
| 228 | { |
| 229 | std::lock_guard<std::mutex> lock(mutex_); |
| 230 | |
| 231 | TaskGroup& task_group = task_groups_[group_id]; |
| 232 | task_group.state_ = TaskGroupState::ALL_TASKS_FINISHED; |
| 233 | *all_task_groups_finished = true; |
| 234 | for (size_t i = 0; i < task_groups_.size(); ++i) { |
| 235 | if (task_groups_[i].state_ != TaskGroupState::ALL_TASKS_FINISHED) { |
| 236 | *all_task_groups_finished = false; |
| 237 | break; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (aborted && *all_task_groups_finished) { |
| 243 | abort_cont_impl_(); |
| 244 | return Status::Cancelled("Scheduler cancelled"); |
| 245 | } |
| 246 | if (!aborted) { |
| 247 | RETURN_NOT_OK(task_groups_[group_id].cont_impl_(thread_id)); |
| 248 | } |
| 249 | return Status::OK(); |
| 250 | } |
| 251 | |
| 252 | Status TaskSchedulerImpl::ExecuteMore(size_t thread_id, int num_tasks_to_execute, |
| 253 | bool execute_all) { |