7#include "../macros.hpp"
10#include "awaitable.hpp"
11#include "awaitable_timer_intf.hpp"
14hi_export_module(hikogui.dispatch.async_task);
16hi_export
namespace hi {
24template<
typename Func,
typename...
Args>
36template<
typename Func,
typename...
Args>
40 using namespace std::literals;
46 if (
not future.valid()) {
51 switch (future.wait_for(0s)) {
52 case std::future_status::deferred:
54 co_return future.get();
56 case std::future_status::ready:
57 co_return future.get();
59 case std::future_status::timeout:
94template<
typename Func,
typename...
Args>
107template<
typename Func,
typename...
Args>
115 } -> std::same_as<ResultType>;
122 } -> std::same_as<ResultType>;
129 } -> std::same_as<ResultType>;
137 } -> std::same_as<ResultType>;
144 } -> std::same_as<task<ResultType>>;
151 } -> std::same_as<task<ResultType>>;
158 } -> std::same_as<task<ResultType>>;
166 } -> std::same_as<task<ResultType>>;
196template<
typename Func,
typename...
Args>
214 hi_static_no_default();
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr auto cancel_features_v
The value of the hi::cancel_features<> type trait.
Definition async_task.hpp:108
cancel_features_type
Features of an invocable.
Definition async_task.hpp:71
@ none
This invocable does not have extra arguments.
@ stop_and_progress
The extra arguments are a std::stop_token, followed by a hi::progress_token.
@ progress
The extra argument is a hi::progress_token.
@ stop
The extra argument is a std::stop_token.
std::invoke_result_t< Func, Args... > async_task(Func func, Args... args)
Run a function asynchronously as a co-routine task.
Definition async_task.hpp:25
auto cancelable_async_task(Func func, std::stop_token stop_token, ::hi::progress_token progress_token, Args... args)
Run a function asynchronously as a co-routine task.
Definition async_task.hpp:197
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Type trait to retrieve the cancel feautes of a invokable.
Definition async_task.hpp:95
Token to pass to a function to report its progress.
Definition progress.hpp:23
Definition async_task.hpp:112
Definition async_task.hpp:119
Definition async_task.hpp:126
Definition async_task.hpp:133
Definition async_task.hpp:141
Definition async_task.hpp:148
Definition async_task.hpp:155
Definition async_task.hpp:162
A concept for a callable that may be use in cancelable_async_task().
Definition async_task.hpp:173