19#include "pw_async2/poll.h"
20#include "pw_async2/task.h"
21#include "pw_function/function.h"
26template <
typename T = ReadyType,
bool kReschedule = false>
32 using Callback = std::conditional_t<std::is_same_v<T, ReadyType>,
37 : callback_(std::move(callback)), pendable_(std::move(pendable)) {}
46 if constexpr (std::is_same_v<T, ReadyType>) {
49 callback_(std::move(*poll));
52 if constexpr (kReschedule) {
74template <
typename T = ReadyType>
84template <
typename T = ReadyType>
90 std::invoke_result_t<
decltype(kFunc),
Context&>>::Type>
93 std::forward<
decltype(kFunc)>(kFunc));
100 typename T =
typename UnwrapPoll<
101 std::invoke_result_t<
decltype(kMemberFunc), Class&, Context&>>::Type>
102OneshotCallbackTask<T> OneshotCallbackTaskFor(Class& obj,
Callback&& callback) {
103 return OneshotCallbackTask<T>(
104 std::forward<Callback>(callback),
105 [&obj](Context& cx) {
return std::invoke(kMemberFunc, &obj, cx); });
110 typename T =
typename UnwrapPoll<
111 std::invoke_result_t<
decltype(kFunc), Context&>>::Type>
112RecurringCallbackTask<T> RecurringCallbackTaskFor(
Callback&& callback) {
113 return RecurringCallbackTask<T>(std::forward<Callback>(callback),
114 std::forward<
decltype(kFunc)>(kFunc));
121 typename T =
typename UnwrapPoll<
122 std::invoke_result_t<
decltype(kMemberFunc), Class&, Context&>>::Type>
123RecurringCallbackTask<T> RecurringCallbackTaskFor(Class& obj,
125 return RecurringCallbackTask<T>(
126 std::forward<Callback>(callback),
127 [&obj](Context& cx) {
return std::invoke(kMemberFunc, &obj, cx); });
Definition: callback_task.h:27
Poll DoPend(Context &cx) final
Definition: callback_task.h:40
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
fit::callback_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Callback
Definition: function.h:128