5#include "../api_status.h"
6#include "init_threading_params.h"
7#include "type_aliases.h"
15namespace cl::threading {
16 template <
typename T>
class async_result;
17 template <
typename T> async_result<T> schedule_work(
const typed_work<T>& work);
50 api_status init(
const init_threading_params& p);
57 api_status shutdown();
59 template <
typename TIn>
62 std::shared_future<TIn> future;
65 explicit async_result(
const std::shared_future<TIn>& future)
68 template <
typename TOut>
70 return schedule_work<TOut>([fut=future, f]() {
71 const auto value = fut.get();
84 std::shared_future<void> future;
88 : future{std::move(future)} {}
90 template <
typename TOut>
92 return schedule_work<TOut>([fut=future, f]() {
103 template <
typename T>
104 async_handler internal::create_task_handler(
const cl::threading::typed_work<T>& work) {
112 async_result<T> schedule_work(
const cl::threading::typed_work<T>& work) {
114 auto task = std::make_unique<typed_task>();
115 auto future = task->promise.get_future();
118 task->exec = internal::create_task_handler(work);
122 const auto sched = get_scheduler();
124 w->schedule(std::move(task));
126 return async_result<T>(future.share());
Definition: threading_module.h:60
Definition: async_worker.h:7
Definition: async_task.h:11
Definition: async_task.h:6
async_handler create_task_handler(const cl::threading::typed_work< T > &work)
Definition: threading_module.h:104
scheduler * get_scheduler()
Get the active scheduler for the task pool.
Definition: threading_module.cpp:64