19#include "pw_async2/context.h"
20#include "pw_async2/internal/lock.h"
21#include "pw_async2/task.h"
22#include "pw_async2/waker.h"
23#include "pw_containers/intrusive_list.h"
24#include "pw_sync/lock_annotations.h"
30using PendOutputOf =
typename decltype(std::declval<T>().Pend(
31 std::declval<Context&>()))::value_type;
96 std::lock_guard lock(internal::lock());
97 return PopTaskToRunLocked();
114 std::lock_guard lock(internal::lock());
115 Task* task = PopTaskToRunLocked();
116 has_posted_tasks = task !=
nullptr || !sleeping_.empty();
124 std::lock_guard lock(internal::lock());
126 return PopTaskToRunLocked();
190 void RemoveWokenTaskLocked(
Task& task)
194 void RemoveSleepingTaskLocked(Task& task)
196 sleeping_.remove(task);
198 void AddSleepingTaskLocked(Task& task)
200 sleeping_.push_front(task);
206 void LogTaskWakers(
const Task& task)
215 wants_wake_.store(
true, std::memory_order_relaxed);
219 return wants_wake_.exchange(
false, std::memory_order_relaxed);
223 IntrusiveList<Task> sleeping_
PW_GUARDED_BY(internal::lock());
226 std::atomic<bool> wants_wake_
PW_GUARDED_BY(internal::lock()) =
false;
Definition: dispatcher_for_test.h:53
Definition: dispatcher.h:53
Task * PopTaskToRun(bool &has_posted_tasks)
Definition: dispatcher.h:112
bool PopAndRunAllReadyTasks()
RunTaskResult
Definition: dispatcher.h:131
@ kDeregistered
The task was removed from the dispatcher by another thread.
Definition: dispatcher.h:136
@ kActive
The task is still posted to the dispatcher.
Definition: dispatcher.h:133
@ kCompleted
The task finished running.
Definition: dispatcher.h:139
Task * PopSingleTaskForThisWake()
Definition: dispatcher.h:123
void LogRegisteredTasks()
RunTaskResult RunTask(Task &task)
Task * PopTaskToRun()
Definition: dispatcher.h:95
Definition: intrusive_list.h:88
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60
#define PW_NO_LOCK_SAFETY_ANALYSIS
Definition: lock_annotations.h:292
#define PW_EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: lock_annotations.h:146
#define PW_LOCKS_EXCLUDED(...)
Definition: lock_annotations.h:176