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;
138 static constexpr log::Token kDefaultName =
144 constexpr Task(log::Token name, OwnedTag)
145 : owned_by_dispatcher_(true), name_(name) {}
175 PW_DASSERT(state_ == State::kUnposted);
176 PW_DASSERT(dispatcher_ ==
nullptr);
177 state_ = State::kWoken;
178 dispatcher_ = &dispatcher;
183 state_ = State::kUnposted;
184 dispatcher_ =
nullptr;
185 RemoveAllWakersLocked();
189 state_ = State::kRunning;
206 kCompletedNeedsDestroy,
234 enum class State :
unsigned char {
237 kDeregisteredButRunning,
243 State state_
PW_GUARDED_BY(internal::lock()) = State::kUnposted;
245 bool owned_by_dispatcher_
PW_GUARDED_BY(internal::lock()) =
false;
253 Dispatcher* dispatcher_
PW_GUARDED_BY(internal::lock()) =
nullptr;
256 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:99
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