MCPcopy Create free account
hub / github.com/davisking/dlib / async

Function async

dlib/threads/async.h:45–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 typename ...Args
44 >
45 std::future<typename impl::result_of<Function(Args...)>::type> async(
46 thread_pool& tp,
47 Function&& f,
48 Args&&... args
49 )
50 {
51 using return_type = typename impl::result_of<Function(Args...)>::type;
52 using task_type = std::packaged_task<return_type()>;
53 auto task = std::make_shared<task_type>(std::bind(std::forward<Function>(f), std::forward<Args>(args)...));
54 auto ret = task->get_future();
55 tp.add_task_by_value([task]() {(*task)();});
56 return ret;
57 }
58
59// ----------------------------------------------------------------------------------------
60

Callers 2

test_asyncFunction · 0.85
mainFunction · 0.85

Calls 2

bindClass · 0.85
add_task_by_valueMethod · 0.80

Tested by 1

test_asyncFunction · 0.68