| 174 | } |
| 175 | |
| 176 | void MutationBatcher::ReapBackgroundTasks() { |
| 177 | std::unique_lock lk(mu_); |
| 178 | // Remove any tasks that have completed. This would not be needed if |
| 179 | // we had a fully asynchronous `AsyncCommit()` function in Cloud Spanner. |
| 180 | background_tasks_.erase( |
| 181 | std::remove_if(background_tasks_.begin(), background_tasks_.end(), |
| 182 | [](auto& t) { |
| 183 | using namespace std::chrono_literals; |
| 184 | return t.wait_for(10ms) == std::future_status::ready; |
| 185 | }), |
| 186 | background_tasks_.end()); |
| 187 | } |
| 188 | |
| 189 | void MutationBatcher::FlushIfNeeded(std::unique_lock<std::mutex> const& lk) { |
| 190 | if (items_.size() >= kEfficientRowLimit) return Flush(lk); |