16#include "pw_assert/assert.h"
17#include "pw_async2/context.h"
18#include "pw_async2/internal/lock.h"
19#include "pw_async2/poll.h"
20#include "pw_containers/intrusive_forward_list.h"
21#include "pw_containers/intrusive_list.h"
22#include "pw_log/tokenized_args.h"
23#include "pw_sync/lock_annotations.h"
30#define PW_ASYNC_TASK_NAME(name) PW_LOG_TOKEN_EXPR("pw_async2", name)
72 explicit constexpr Task(log::Token name = kDefaultName) : name_(name) {}
76 Task& operator=(
const Task&) =
delete;
134 static constexpr log::Token kDefaultName =
140 constexpr Task(log::Token name, OwnedTag)
141 : owned_by_dispatcher_(true), name_(name) {}
171 PW_DASSERT(state_ == State::kUnposted);
172 PW_DASSERT(dispatcher_ ==
nullptr);
173 state_ = State::kWoken;
174 dispatcher_ = &dispatcher;
179 state_ = State::kUnposted;
180 dispatcher_ =
nullptr;
181 RemoveAllWakersLocked();
185 state_ = State::kRunning;
202 kCompletedNeedsDestroy,
230 enum class State :
unsigned char {
233 kDeregisteredButRunning,
239 State state_
PW_GUARDED_BY(internal::lock()) = State::kUnposted;
241 bool owned_by_dispatcher_
PW_GUARDED_BY(internal::lock()) =
false;
249 Dispatcher* dispatcher_
PW_GUARDED_BY(internal::lock()) =
nullptr;
252 IntrusiveForwardList<Waker> wakers_
PW_GUARDED_BY(internal::lock());
Definition: dispatcher.h:53
Definition: owned_task.h:31
virtual Poll DoPend(Context &)=0
Poll Pend(Context &cx)
Definition: task.h:101
bool IsRegistered() const
constexpr Task(log::Token name=kDefaultName)
Definition: task.h:72
Definition: intrusive_list.h:88
#define PW_LOG_TOKEN(...)
Definition: tokenized_args.h:63
#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