19#include "pw_async2/future.h"
20#include "pw_async2/poll.h"
21#include "pw_async2/task.h"
22#include "pw_function/function.h"
27template <
typename FutureType>
28using CallbackType = std::conditional_t<
29 std::is_same_v<typename FutureType::value_type, ReadyType>,
31 Function<void(
typename FutureType::value_type)>>;
42template <
typename FutureType,
43 typename Func = internal::CallbackType<FutureType>>
46 using value_type =
typename FutureType::value_type;
48 static_assert(is_future_v<FutureType>,
49 "FutureCallbackTask can only be used with Future types");
52 : future_(std::move(future)), callback_(std::move(callback)) {}
61 if constexpr (std::is_same_v<value_type, ReadyType>) {
64 callback_(std::move(*poll));
74template <
typename FutureType,
typename Func>
75FutureCallbackTask(FutureType&&, Func&&)
76 -> FutureCallbackTask<FutureType, Func>;
Definition: callback_task.h:44
Poll DoPend(Context &cx) final
Definition: callback_task.h:55
constexpr bool IsPending() const noexcept
Returns whether or not this value is Pending.
Definition: poll.h:136
constexpr PendingType Pending()
Returns a value indicating that an operation was not yet able to complete.
Definition: poll.h:271
constexpr Poll Ready()
Returns a value indicating completion.
Definition: poll.h:255
fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Function
Definition: function.h:73