19#include "pw_async2/runnable_dispatcher.h"
20#include "pw_async2/waker.h"
26template <
typename Pendable>
29 using value_type = PendOutputOf<Pendable>;
31 : pendable_(pendable), output_(
Pending()) {}
37 output_ = pendable_.Pend(cx);
56template <
typename Native>
74 template <
typename Pendable>
88 return task.TakePoll();
108 return tasks_polled_.load(std::memory_order_relaxed);
113 return tasks_completed_.load(std::memory_order_relaxed);
118 return wake_count_.load(std::memory_order_relaxed);
123 class IdleTask :
public Task {
127 ~IdleTask()
override;
130 should_complete_.store(
true, std::memory_order_relaxed);
131 std::move(waker_).Wake();
136 should_complete_.store(
false, std::memory_order_relaxed);
140 Poll<> DoPend(Context& cx)
override;
143 std::atomic<bool> should_complete_ =
false;
148 bool DoRunUntilStalled()
override;
158 bool blocking_is_allowed_ =
false;
159 std::atomic<int> blocking_until_released_ =
false;
162 std::atomic<uint32_t> tasks_polled_ = 0u;
163 std::atomic<uint32_t> tasks_completed_ = 0u;
164 std::atomic<uint32_t> wake_count_ = 0u;
169#include "pw_async2_backend/native_dispatcher_for_test.h"
171namespace pw::async2 {
Definition: dispatcher_for_test.h:57
Definition: runnable_dispatcher.h:24
bool IsRegistered() const
Definition: dispatcher_for_test.h:27
#define PW_ASYNC_TASK_NAME(name)
Generates a token for use as a task name.
Definition: task.h:30
constexpr Poll Readiness() const noexcept
Definition: poll.h:140
constexpr PendingType Pending()
Returns a value indicating that an operation was not yet able to complete.
Definition: poll.h:271
bool RunUntilStalled()
Definition: runnable_dispatcher.h:30
void RunToCompletionUntilReleased()
uint32_t wake_count() const
Returns the total number of times the dispatcher has been woken.
Definition: dispatcher_for_test.h:117
DispatcherForTestFacade()=default
DispatcherForTest is default constructible.
uint32_t tasks_polled() const
Definition: dispatcher_for_test.h:107
Poll DoPend(Context &cx) final
Definition: dispatcher_for_test.h:36
uint32_t tasks_completed() const
Returns the total number of tasks the dispatcher has run to completion.
Definition: dispatcher_for_test.h:112
void DoWaitForWake() override
void AllowBlocking()
Definition: dispatcher_for_test.h:72
#define PW_LOCKS_EXCLUDED(...)
Definition: lock_annotations.h:176