| 87 | // Asynchronous execution for tasks when execution order matters. |
| 88 | template <typename Task> |
| 89 | static ResultPtr RunSequential(Task && t) |
| 90 | { |
| 91 | ResultPtr result(new Result(Instance().GetNextId())); |
| 92 | auto const pushResult = Instance().m_sequentialWorkerThread.Push([result, t = std::forward<Task>(t)]() mutable |
| 93 | { |
| 94 | t(); |
| 95 | Instance().Notify(result->Finish()); |
| 96 | }); |
| 97 | |
| 98 | if (!pushResult.m_isSuccess) |
| 99 | return {}; |
| 100 | |
| 101 | return result; |
| 102 | } |
| 103 | |
| 104 | private: |
| 105 | static DrapeRoutine & Instance(bool reinitialize = false) |