MCPcopy Create free account
hub / github.com/colmap/colmap / AddTask

Method AddTask

src/colmap/util/threading.h:368–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366
367template <class func_t, class... args_t>
368auto ThreadPool::AddTask(func_t&& f, args_t&&... args)
369 -> std::shared_future<result_of_t<func_t, args_t...>> {
370 using return_t = result_of_t<func_t, args_t...>;
371
372 auto task = std::make_shared<std::packaged_task<return_t()>>(
373 std::bind(std::forward<func_t>(f), std::forward<args_t>(args)...));
374
375 std::shared_future<return_t> result = task->get_future().share();
376
377 {
378 std::unique_lock<std::mutex> lock(mutex_);
379 if (stopped_) {
380 throw std::runtime_error("Cannot add task to stopped thread pool.");
381 }
382 tasks_.emplace([task = std::move(task), result]() {
383 (*task)();
384 return [result = std::move(result)]() { result.get(); };
385 });
386 }
387
388 task_condition_.notify_one();
389
390 return result;
391}
392
393template <typename T>
394JobQueue<T>::JobQueue() : JobQueue(std::numeric_limits<size_t>::max()) {}

Callers 15

NextMethod · 0.80
RunMethod · 0.80
RigVerificationFunction · 0.80
RunMethod · 0.80
RunModelSplitterFunction · 0.80
ReestimateRelativePosesFunction · 0.80
LoadMethod · 0.80
DelaunayMeshingFunction · 0.80
RunMethod · 0.80
ProcessProblemMethod · 0.80
RunMethod · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64