MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / ReapBackgroundTasks

Method ReapBackgroundTasks

getting-started/gke/index_gcs.cc:176–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176void 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
189void MutationBatcher::FlushIfNeeded(std::unique_lock<std::mutex> const& lk) {
190 if (items_.size() >= kEfficientRowLimit) return Flush(lk);

Callers 1

IndexGcsPrefixFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected