MCPcopy Create free account
hub / github.com/cactus-compute/cactus / enqueue

Method enqueue

cactus/kernel/kernel_utils.h:339–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337
338 template<typename F>
339 auto enqueue(F&& f) -> std::future<decltype(f())> {
340 using return_type = decltype(f());
341
342 auto task = std::make_shared<std::packaged_task<return_type()>>(
343 std::forward<F>(f)
344 );
345
346 std::future<return_type> res = task->get_future();
347
348 {
349 std::lock_guard<std::mutex> lock(mutex);
350 pending_tasks.fetch_add(1, std::memory_order_relaxed);
351 tasks.emplace_back([task](){ (*task)(); });
352 }
353 work_available.notify_one();
354
355 return res;
356 }
357
358 template<typename F>
359 void enqueue_batch(size_t total_work, F task_func) {

Callers 4

parallel_forFunction · 0.45
parallel_reduceFunction · 0.45

Calls

no outgoing calls

Tested by 1