| 53 | |
| 54 | template <typename Task> |
| 55 | static ResultPtr Run(Task && t) |
| 56 | { |
| 57 | ResultPtr result(new Result(Instance().GetNextId())); |
| 58 | auto const pushResult = Instance().m_workerThread.Push([result, t = std::forward<Task>(t)]() mutable |
| 59 | { |
| 60 | t(); |
| 61 | Instance().Notify(result->Finish()); |
| 62 | }); |
| 63 | |
| 64 | if (!pushResult.m_isSuccess) |
| 65 | return {}; |
| 66 | |
| 67 | return result; |
| 68 | } |
| 69 | |
| 70 | template <typename Task> |
| 71 | static ResultPtr RunDelayed(base::DelayedThreadPool::Duration const & duration, Task && t) |