| 1670 | } |
| 1671 | |
| 1672 | void DoRestartTask(std::shared_ptr<State> state, util::Mutex::Guard guard) { |
| 1673 | // If we get here we are actually going to start a new task so let's create a |
| 1674 | // task_finished future for it |
| 1675 | state->task_finished = Future<>::Make(); |
| 1676 | state->reading = true; |
| 1677 | auto spawn_status = io_executor->Spawn( |
| 1678 | [state]() { BackgroundGenerator::WorkerTask(std::move(state)); }); |
| 1679 | if (!spawn_status.ok()) { |
| 1680 | // If we can't spawn a new task then send an error to the consumer (either via a |
| 1681 | // waiting future or the queue) and mark ourselves finished |
| 1682 | state->finished = true; |
| 1683 | state->task_finished = Future<>(); |
| 1684 | if (waiting_future.has_value()) { |
| 1685 | auto to_deliver = std::move(waiting_future.value()); |
| 1686 | waiting_future.reset(); |
| 1687 | guard.Unlock(); |
| 1688 | to_deliver.MarkFinished(spawn_status); |
| 1689 | } else { |
| 1690 | ClearQueue(); |
| 1691 | queue.push(spawn_status); |
| 1692 | } |
| 1693 | } |
| 1694 | } |
| 1695 | |
| 1696 | Future<T> RestartTask(std::shared_ptr<State> state, util::Mutex::Guard guard, |
| 1697 | Future<T> next) { |
no test coverage detected