Go to the documentation of this file.
15 #ifndef GRPC_CORE_LIB_PROMISE_ACTIVITY_H
16 #define GRPC_CORE_LIB_PROMISE_ACTIVITY_H
27 #include "absl/base/thread_annotations.h"
28 #include "absl/status/status.h"
29 #include "absl/types/optional.h"
30 #include "absl/types/variant.h"
31 #include "absl/utility/utility.h"
53 virtual void Drop() = 0;
78 if (
auto* wakeable =
Take()) wakeable->Wakeup();
138 bool is_current()
const {
return this == g_current_activity_; }
146 g_current_activity_ = activity;
165 namespace promise_detail {
167 template <
typename Context>
179 template <
typename Context>
191 template <
typename Context,
typename Deleter>
201 std::unique_ptr<Context, Deleter>
value_;
204 template <
typename HeldContext>
207 template <
typename... Contexts>
290 virtual void Cancel() = 0;
292 void Ref() {
refs_.fetch_add(1, std::memory_order_relaxed); }
294 if (1 ==
refs_.fetch_sub(1, std::memory_order_acq_rel)) {
338 template <
class F,
class WakeupScheduler,
class OnDone,
typename... Contexts>
346 OnDone on_done, Contexts&&... contexts)
455 ScopedContext contexts(
this);
465 ScopedContext contexts(
this);
466 Construct(&promise_holder_.promise, promise_factory.Once());
477 auto r = promise_holder_.promise();
478 if (
auto*
status = absl::get_if<kPollReadyIdx>(&
r)) {
520 template <
typename Factory,
typename WakeupScheduler,
typename OnDone,
521 typename... Contexts>
523 WakeupScheduler wakeup_scheduler, OnDone on_done,
524 Contexts&&... contexts) {
529 std::move(on_done), std::forward<Contexts>(contexts)...));
534 #endif // GRPC_CORE_LIB_PROMISE_ACTIVITY_H
virtual Waker MakeNonOwningWaker()=0
PromiseActivity(F promise_factory, WakeupScheduler wakeup_scheduler, OnDone on_done, Contexts &&... contexts)
Handle * RefHandle() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
ActionDuringRun GotActionDuringRun() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
Waker MakeOwningWaker() final
static bool have_current()
static Activity * current()
Status CancelledError(absl::string_view message)
ScopedActivity & operator=(const ScopedActivity &)=delete
typename ContextHolder< HeldContext >::ContextType ContextTypeFromHeld
std::atomic< uint32_t > refs_
Waker(Waker &&other) noexcept
std::atomic< bool > done_
ActivityPtr MakeActivity(Factory promise_factory, WakeupScheduler wakeup_scheduler, OnDone on_done, Contexts &&... contexts)
absl::Status IntoStatus(absl::StatusOr< T > *status)
ScopedActivity(Activity *activity)
friend H AbslHashValue(H h, const Waker &w)
GPR_NO_UNIQUE_ADDRESS bool done_ ABSL_GUARDED_BY(mu())
GPR_NO_UNIQUE_ADDRESS std::atomic< bool > wakeup_scheduled_
ScopedContext(ActivityContexts *contexts)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION()
TestInstance::Result Result
#define ABSL_LOCK_RETURNED(x)
Waker & operator=(const Waker &)=delete
#define ABSL_EXCLUSIVE_LOCKS_REQUIRED(...)
Waker MakeNonOwningWaker() final
void RunScheduledWakeup()
OrphanablePtr< Activity > ActivityPtr
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
ContextHolder(Context *value)
std::unique_ptr< Context, Deleter > value_
ActivityContexts(Contexts &&... contexts)
void ForceImmediateRepoll() final
absl::optional< ResultType > RunStep() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu())
decltype(PromiseFactoryImpl(std::move(f_))) Promise
typename Factory::Promise::Result ResultType
virtual Waker MakeOwningWaker()=0
void Step() ABSL_LOCKS_EXCLUDED(mu())
void Construct(T *p, Args &&... args)
Waker & operator=(Waker &&other) noexcept
static GPR_THREAD_LOCAL(Activity *) g_current_activity_
PromiseFactory< void, F > Factory
void DropHandle() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
void Unlock() ABSL_UNLOCK_FUNCTION()
#define ABSL_LOCKS_EXCLUDED(...)
std::unique_ptr< T, Deleter > OrphanablePtr
virtual void ForceImmediateRepoll()=0
void MarkDone() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu())
GPR_NO_UNIQUE_ADDRESS OnDone on_done_
absl::optional< ResultType > StepLoop() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu())
~FreestandingActivity() override
Activity *const prior_activity_
~PromiseActivity() override
GPR_NO_UNIQUE_ADDRESS WakeupScheduler wakeup_scheduler_
typename Factory::Promise Promise
absl::optional< ResultType > Start(Factory promise_factory) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu())
constexpr T && forward(absl::remove_reference_t< T > &t) noexcept
void SetActionDuringRun(ActionDuringRun action) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_)
Waker(Wakeable *wakeable)
ActionDuringRun action_during_run_ ABSL_GUARDED_BY(mu_)
ContextHolder(std::unique_ptr< Context, Deleter > value)
void AssertHeld() ABSL_ASSERT_EXCLUSIVE_LOCK()
bool operator==(const Waker &other) const noexcept
ContextHolder(Context value)
T exchange(T &obj, U &&new_value)
GPR_NO_UNIQUE_ADDRESS Promise promise
Mutex * mu() ABSL_LOCK_RETURNED(mu_)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:29