| 77 | } |
| 78 | |
| 79 | Async<void> CreateAsyncVoidTask_(const std::function<void (void)>& process, const size_t index) { |
| 80 | // Increment the working # |
| 81 | threadsWorking_[index]->fetch_add(1); |
| 82 | |
| 83 | const auto processWithHook = [this, index, process]() { |
| 84 | process(); |
| 85 | // Decrement working counter |
| 86 | threadsWorking_[index]->fetch_sub(1); |
| 87 | }; |
| 88 | |
| 89 | auto as = Async<void>(*taskThreads_[index].get(), processWithHook); |
| 90 | return as; |
| 91 | } |
| 92 | |
| 93 | size_t GetNextThreadIndexForTask_() { |
| 94 | if (taskThreads_.size() == 0) throw std::runtime_error("Task threads size equal to 0"); |