| 103 | // add new work item to the pool |
| 104 | template <class F, class... Args> |
| 105 | auto threadPoolEnqueue(F &&f, Args &&...args) |
| 106 | -> std::shared_future<typename std::invoke_result_t<F, Args...>> |
| 107 | { |
| 108 | using return_type = typename std::invoke_result_t<F, Args...>; |
| 109 | |
| 110 | auto task = std::make_shared<std::packaged_task<return_type()>>( |
| 111 | std::bind(std::forward<F>(f), std::forward<Args>(args)...)); |
| 112 | |
| 113 | std::shared_future<return_type> res = task->get_future().share(); |
| 114 | this->threadPoolTaskEnqueue([task, res]() { |
| 115 | (*task)(); |
| 116 | // Without a future.get() any exceptions are dropped on the floor |
| 117 | res.get(); |
| 118 | }); |
| 119 | return res; |
| 120 | } |
| 121 | |
| 122 | UString getDataDir() const; |
| 123 | UString getCDPath() const; |
no test coverage detected