18#include "pw_assert/assert.h"
19#include "pw_async2/internal/config.h"
20#include "pw_async2/internal/lock.h"
21#include "pw_containers/intrusive_forward_list.h"
22#include "pw_log/tokenized_args.h"
23#include "pw_sync/lock_annotations.h"
32template <
typename Callable>
33[[nodiscard]]
constexpr auto InvokeWithNodiscard(Callable&& callable) {
37[[nodiscard]]
bool CloneWaker(Waker& waker_in,
39 log::Token wait_reason = log::kDefaultToken)
58#define PW_ASYNC_STORE_WAKER(context, waker_out, wait_reason_string) \
60 bool waker_had_space = \
61 PW_ASYNC_TRY_STORE_WAKER(context, waker_out, wait_reason_string); \
62 PW_ASSERT(waker_had_space); \
78#define PW_ASYNC_TRY_STORE_WAKER(context, waker_out, wait_reason_string) \
79 _PW_ASYNC_TRY_GET_WAKER(::pw::async2::internal::StoreWaker, \
96#define PW_ASYNC_CLONE_WAKER(waker_in, waker_out, wait_reason_string) \
98 bool waker_had_space = \
99 PW_ASYNC_TRY_CLONE_WAKER(waker_in, waker_out, wait_reason_string); \
100 PW_ASSERT(waker_had_space); \
115#define PW_ASYNC_TRY_CLONE_WAKER(waker_in, waker_out, wait_reason_string) \
116 _PW_ASYNC_TRY_GET_WAKER(::pw::async2::internal::CloneWaker, \
124#define _PW_ASYNC_TRY_GET_WAKER(func, source, waker_out, wait_reason_string) \
125 ::pw::async2::internal::InvokeWithNodiscard( \
126 [&]() PW_NO_LOCK_SAFETY_ANALYSIS { \
127 [[maybe_unused]] constexpr const char* \
128 pw_async2_wait_reason_must_be_string = wait_reason_string; \
129 constexpr ::pw::log::Token pw_async2_wait_reason = \
130 PW_LOG_TOKEN("pw_async2", wait_reason_string); \
131 return func(source, waker_out, pw_async2_wait_reason); \
154 constexpr Waker() =
default;
156 *
this = std::move(other);
193 friend
bool internal::CloneWaker(
Waker& waker_in,
195 log::Token wait_reason);
198 std::lock_guard lock(internal::lock());
208 void CloneInto(
Waker& waker_out, log::Token wait_reason)
224#if PW_ASYNC2_DEBUG_WAIT_REASON
225 log::Token wait_reason_ = log::kDefaultToken;
Definition: intrusive_forward_list.h:99
Definition: dispatcher.h:75
Waker & operator=(Waker &&other) noexcept
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60
#define PW_EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: lock_annotations.h:147
#define PW_LOCKS_EXCLUDED(...)
Definition: lock_annotations.h:178