| 1776 | } |
| 1777 | |
| 1778 | void DoRestartTask(std::shared_ptr<State> state, util::Mutex::Guard guard) { |
| 1779 | // If we get here we are actually going to start a new task so let's create a |
| 1780 | // task_finished future for it |
| 1781 | state->task_finished = Future<>::Make(); |
| 1782 | state->reading = true; |
| 1783 | auto spawn_status = io_executor->Spawn( |
| 1784 | [state]() { BackgroundGenerator::WorkerTask(std::move(state)); }); |
| 1785 | if (!spawn_status.ok()) { |
| 1786 | // If we can't spawn a new task then send an error to the consumer (either via a |
| 1787 | // waiting future or the queue) and mark ourselves finished |
| 1788 | state->finished = true; |
| 1789 | state->task_finished = Future<>(); |
| 1790 | if (waiting_future.has_value()) { |
| 1791 | auto to_deliver = std::move(waiting_future.value()); |
| 1792 | waiting_future.reset(); |
| 1793 | guard.Unlock(); |
| 1794 | to_deliver.MarkFinished(spawn_status); |
| 1795 | } else { |
| 1796 | ClearQueue(); |
| 1797 | queue.push(spawn_status); |
| 1798 | } |
| 1799 | } |
| 1800 | } |
| 1801 | |
| 1802 | Future<T> RestartTask(std::shared_ptr<State> state, util::Mutex::Guard guard, |
| 1803 | Future<T> next) { |
no test coverage detected