* Try to flush logged, blocked TakeGrad attempts. */
| 166 | * Try to flush logged, blocked TakeGrad attempts. |
| 167 | */ |
| 168 | void ConditionalAccumulatorBase::FlushUnlocked() { |
| 169 | std::vector<CleanUp> clean_up; |
| 170 | Ref(); |
| 171 | { |
| 172 | mutex_lock lock(mu_); |
| 173 | bool changed; |
| 174 | do { |
| 175 | changed = TryAttemptLocked(&clean_up); |
| 176 | } while (changed); |
| 177 | } |
| 178 | Unref(); |
| 179 | for (const auto& to_clean : clean_up) { |
| 180 | if (to_clean.to_deregister != CancellationManager::kInvalidToken) { |
| 181 | // NOTE(mrry): We can safely ignore the return value of |
| 182 | // DeregisterCallback because the mutex mu_ ensures that the |
| 183 | // cleanup action only executes once. |
| 184 | to_clean.cm->DeregisterCallback(to_clean.to_deregister); |
| 185 | } |
| 186 | to_clean.finished(); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | bool ConditionalAccumulatorBase::TakeGradLockedHelper(OpKernelContext* ctx, |
| 191 | DoneCallback callback) { |
nothing calls this directly
no test coverage detected