MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / threadPoolEnqueue

Method threadPoolEnqueue

framework/framework.h:105–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 12

loadGameMethod · 0.80
updateMethod · 0.80
loadBattleBuildingFunction · 0.80
loadBattleBaseFunction · 0.80
loadBattleBuildingFunction · 0.80
loadBattleVehicleFunction · 0.80
loadGameFunction · 0.80
loadBattleBuildingFunction · 0.80
loadBattleVehicleFunction · 0.80
enterBattleFunction · 0.80
mixingCallbackMethod · 0.80
playMusicMethod · 0.80

Calls 2

threadPoolTaskEnqueueMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected