15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_POLLING_POLICY_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_POLLING_POLICY_H
18 #include "google/cloud/internal/backoff_policy.h"
19 #include "google/cloud/internal/retry_policy.h"
20 #include "google/cloud/status.h"
21 #include "google/cloud/version.h"
93 template <
typename Retry,
typename Backoff>
97 : retry_prototype_(std::move(retry_policy)),
98 backoff_prototype_(std::move(backoff_policy)),
99 retry_clone_(maybe_deref(retry_prototype_).clone()),
100 backoff_clone_(maybe_deref(backoff_prototype_).clone()) {}
105 backoff_prototype_));
109 return retry_clone_->OnFailure(status);
113 return backoff_clone_->OnCompletion();
117 template <
typename T>
118 T& maybe_deref(T& v) {
121 template <
typename T>
122 T& maybe_deref(std::shared_ptr<T>& v) {
126 Retry retry_prototype_;
127 Backoff backoff_prototype_;
129 std::unique_ptr<internal::RetryPolicy> retry_clone_;
130 std::unique_ptr<internal::BackoffPolicy> backoff_clone_;